Python mysql.connector update error code 1064
I am trying to insert an array of ints. I use the exact same code serval lines above to update "processed = 1" from 0. The code looks like this:
cursor.executemany('''UPDATE %s SET flag = "bad" WHERE id = %%s''' % seed_table, (bad_list))
The error that I am getting and I printed out the list and I also checked to make sure that the nums there are ints:
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
Any help on why this wouldn't work when I have been using this exact syntax successfully other places in the same code would be greatly appreciated.
UPDATE: I print what I was trying to execute:
UPDATE table_name SET flag = "bad" WHERE id = %s [231, 233, 234, 235, 236, 237, 239, 240]
this isnt working for some reason and below here is an example of one that is working fine:
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')]
You can convert the list of ids to a list of tuples:
cursor.executemany('''UPDATE TABLE_NAME SET flag = "bad" WHERE id=%s''',
[(_id,) for _id in list_of_ids]