使用python往mysql批量插入數(shù)據(jù)時,報錯not all arguments converted我用這段命令可以往mysql數(shù)據(jù)庫插入數(shù)據(jù)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進行數(shù)據(jù)插入這是我的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貢獻2012條經(jīng)驗 獲得超12個贊
%s和前面?zhèn)魅氲膮?shù)數(shù)量好像不一致,你的%s有9個,你要傳入的users_values里面的值貌似不是9個,這兩個必須一致

月關(guān)寶盒
TA貢獻1772條經(jīng)驗 獲得超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)
另外檢查一下格式化的數(shù)據(jù)和數(shù)據(jù)庫的數(shù)據(jù)類型,大概。
添加回答
舉報
0/150
提交
取消