Inclusion Criteria:  Women aged 18 to 40 years old Patients with confirmed history of T2D or patients who are newly diagnosed with T2D by oral glucose tolerance test (OGTT) during pregnancy (diagnostic criteria refer to ADA 2020 guideline for T2D). Women with singleton pregnancy at 4 to 20 weeks of gestation, whose blood glucose fails to achieved glucose target after adequate lifestyle intervention with or without the prescription of basal insulin (i.e. fasting blood glucose above 5.3 mmol/L, or one hour postprandial blood glucose above 7.8 mmol/L, or two hour postprandial blood glucose above 6.7 mmol/L), and need to start intensive insulin therapy (MDI or insulin pump) according to the evaluation of endocrinologists. Patients who are willing be followed up by the Third Hospital of Peking University in the whole process of pregnancy until 6 weeks of postpartum, and promise that they will provide the results of relative prenatal examinations and perinatal medical records if they are transferred to another hospital for special reasons. Patients who can pass the compliance test and agree to conduct self-monitoring of blood glucose (SMBG) at least 7 times a day during pregnancy. Patients who volunteer to participate the trial and agree to sign informed consent.  Exclusion Criteria:  Patients with T1D, special type of diabetes and gestational diabetes. Patients who have received intensive insulin therapy (MDI or insulin pump) or premixed fixed doses of insulin before enrollment in this trial. Patients who refuse to use insulin pump or CGM devices. Patients who are not recommended by obstetrician to continue their pregnancy due to comorbidity and high risk of pregnancy. The comorbidities include but not limited to the following diseases: proliferative retinopathy, chronic kidney disease (eGFR less than 60 ml /min/1.73 with or without heavy proteinuria), known coronary heart disease and cerebrovascular disease, autoimmune disease, other diseases requiring exogenous glucocorticoid or immunosuppressive therapy. Patients who received inpatient psychiatric treatment within 6 months before enrollment or still using psychiatric drugs. Participated in other intervention studies.