Python 存储数据到数据库

该博客介绍如何使用Python解析JSON数据,提取DealResult字段,并利用pymongo模块将数据无重复地存储到MongoDB数据库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

数据:

{
    "ResultCount": 2,
    "Code": "200",
    "DealResult": "[{\"HospitalID\":1385899,\"HospitalCode\":\"H108801565\",\"ExternalID\":\"H108801565\",\"HospitalName\":\"浙商银行股份有限公司医务室\",\"RegionId\":23,\"Region\":\"浙江省\",\"CityId\":\"773\",\"City\":\"杭州市\",\"HospitalGradeId\":0,\"HospitalGrade\":null,\"HospitalTypeId\":0,\"HospitalType\":null,\"StopStatusId\":1,\"StopStatus\":\"启用\",\"StatisticsPropertyId\":0,\"StatisticsProperty\":null,\"CountyId\":0,\"County\":null,\"HospitalPropertyId\":0,\"HospitalProperty\":null,\"CustomerAddress\":\"杭州市下城区庆春路288号\",\"HospitalClassificationId\":null,\"HospitalClassification\":null,\"HospitalGradeUnit\":0,\"DoctorNum\":null,\"CertifiedDoctorNum\":0,\"SpecialistNum\":0,\"SectionOfficeNum\":0,\"BedNum\":null,\"DayOutpatientNum\":0.0,\"YearPurchaseAmount\":0.0,\"ExistingProducts\":null,\"TelePhone\":null,\"ZipCode\":null,\"WebSite\":null,\"LegalPerson\":null,\"Canton\":null,\"IsCountyLevelMedicalId\":0,\"IsCountyLevelMedical\":null,\"ProviderRegisterNO\":null,\"OldName\":null,\"Remark\":\"H108801565\",\"ChannelId\":1,\"Channel\":\"生产企业\",\"CreateUserId\":2003610,\"CreateUser\":\"系统管理员03\",\"CreateTime\":\"2022-11-04 16:27:44\",\"UpdateUserId\":2022302,\"UpdateUser\":\"admingww\",\"UpdateTime\":\"2023-09-26 17:18:50\",\"strHospitalMain\":null,\"strDoctor\":[{\"DoctorID\":1062435,\"Doctor\":\"1\",\"DoctorName\":\"1\",\"DoctorCode\":\"1\",\"PhoneNum\":\"1\",\"PositionName\":\"院长\",\"SectionOfficeName\":\"老干部科\",\"HospitalPhoneNum\":null,\"SectionOffice\":9,\"POSITION\":10}],\"strStoreInfo\":[{\"PKID\":13,\"CustomerID\":1385899,\"Company\":\"山西振东安欣生物制药有限公司\",\"Code\":\"H107285861\",\"NAME\":\"北京祥顺康医药有限公司万顺康诊所\",\"ProductCode\":\"60000004\",\"ProductName\":\"碳酸钙D3颗粒\"}],\"strSectionInfo\":[]},{\"HospitalID\":1385955,\"HospitalCode\":\"H108947538\",\"ExternalID\":\"H108947538\",\"HospitalName\":\"周口市淮阳区人民医院\",\"RegionId\":28,\&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@明天更美好

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值