I am doing a sequence of psycopg2 executions with execute_values. It works fine for UPDATE and INSERT statements, but not for DELETE statements.
For example, when I run:
execute_values(db, "DELETE FROM table1 WHERE column1 = %s", [(1,), (2,), (3,)])
I get:
psycopg2.errors.SyntaxError: syntax error at or near ","
LINE 1: DELETE FROM table1 WHERE column1 = (1),(2),(3)
^
However when I run an UPDATE or INSERT with similar code, it works fine, for example:
execute_values(db, "INSERT INTO table1 (column1, column2, column3) VALUES %s",
[(1, foo, bar), (2, foo, bar), (3, foo, bar)])
The docs imply execute_values should work fine with a DELETE statement but don't say so explicitly. However, I don't understand otherwise why I am only getting this error with DELETE statements.