我正在尝试插入一个整数数组。我使用上面完全相同的代码 serval 行从 0 更新“processed = 1”。代码如下所示:
cursor.executemany('''UPDATE %s SET flag = "bad" WHERE id = %%s''' % seed_table, (bad_list))
我得到的错误,我打印出列表,我还检查以确保 nums 有整数:
bad_list: [61, 63, 68, 69]
Error code: 1064
SQLSTATE value: 42000
Error message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1
当我在同一代码中的其他地方成功使用这种确切的语法时,为什么这不起作用的任何帮助将不胜感激。
更新:我打印我试图执行的内容:
UPDATE table_name SET flag = "bad" WHERE id = %s [231, 233, 234, 235, 236, 237, 239, 240]
由于某种原因,这不起作用,下面是一个运行良好的示例:
INSERT INTO table_name (col1, col2, col3, col4, col5, col6, col7,col8) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) [(u'jungkook covers', 1.0, 1.0, 1.0, 18.0, 'all', '2015-08-02', '2015-10-30'), (u'songs for dancing', 2.0, 2.0, 1.0, 9.0, 'all', '2015-08-02', '2015-10-30'), (u'songs', 4.0, 2.0, 0.5, 6.0, 'all', '2015-08-02', '2015-10-30'), (u'music', 1.0, 1.0, 1.0, 7.0, 'all', '2015-08-02', '2015-10-30'), (u'songs about yourself', 3.0, 1.0, 0.3333333333333333, 10.0, 'all', '2015-08-02', '2015-10-30')]