python - 使用python的数据库
问题描述
我的数据 json :
我的代码:
import json
import re
import sqlite3
conn = sqlite3.connect('chinook.db')
cursor = conn.cursor()
c = conn.cursor()
with open('tem.txt', encoding='utf-8-sig') as json_file:
data = json.load(json_file)
for p in data:
data[p] = re.sub("<[^>]+>", "", str(data[p]))
print("%s: %s" % (p, data[p]))
c.execute("insert INTO THINH (THONGTIN, ID) VALUES ('"+ data[p] +"','"+ p +"')")
conn.commit()
我无法将 json 文件中的所有数据都放入我的数据库中?
解决方案
推荐阅读
- dynamics-crm - 如何仅在 Web 客户端 (CRM9.x) 上从全局导航中隐藏快速表单
- javascript - 从 Sails 端点下载文件
- ruby-on-rails - Rails 与 Postgres - 数据库角色特定操作
- java - 使用休眠找不到合适的驱动程序
- c# - 是否可以使用 DbContext 代码从 WebApi 访问 JSON 数据?
- android - 片段 onCreateView 已调用但未显示
- html - 翻译取决于内容大小
- android - 更改材料选项卡项目的语言
- codeigniter - 在 codeigniter 中更改文件上传的自定义错误消息
- laravel - 找不到驱动程序 (SQL: select * from `users` where `email` = admin@gmail.com limit 1)"