使用python往mysql批量插入数据时,报错not all arguments converted我用这段命令可以往mysql数据库插入数据insert into moderation_task(id, media_id, user_id, media_url_or_path, media_title, media_source,
created, updated, status, is_del) values(105, 75, 1, '/audit_source/origin_video/2360deca955311e8bbd966d3bcd97028.mp4', '006.mp4', 'abc', '2018-08-01 06:21:37', '2018-08-01 06:21:37', 0, 0)但是无法使用python进行数据插入这是我的python代码users_values = [] for i in range(105, 195, 1):
users_values.append((i, 75, 1, '/audit_source/origin_video/2360deca955311e8bbd966d3bcd97028.mp4', '006.mp4', 'abc', '2018-08-01 06:21:37', '2018-08-01 06:21:37', 0, 0)) print(users_values)
cs1.executemany('insert into moderation_task(id, media_id, user_id, media_url_or_path, media_title, media_source, created, updated, status, is_del) value(%s, %s, %s, %s, %s, %s, %s, %s, %s)',
users_values)每次都是这个错误
2 回答
月关宝盒
TA贡献1772条经验 获得超5个赞
cs1.executemany('insert into moderation_task(id, media_id, user_id, media_url_or_path, media_title, media_source, created, updated, status, is_del) value(%s, %s, %s, %s, %s, %s, %s, %s, %s)',users_values)
字段有10个,格式化的值只有9个吧
cs1.executemany('insert into moderation_task(id, media_id, user_id, media_url_or_path, media_title, media_source, created, updated, status, is_del) value(%s, %s, %s, %s, %s, %s, %s, %s, %s,%s)',users_values)
另外检查一下格式化的数据和数据库的数据类型,大概。
添加回答
举报
0/150
提交
取消