Say I have a tuple of IDs:
ids = (1,2,3,4,5)
Using python, I want to delete every row from a database table (called schedule) that doesn't contain one of these IDs.
This is what I've tried:
delete_stmt = "DELETE from schedule WHERE ID NOT IN %s"
...
cursor.execute(delete_stmt, ids)
I've excluded the unnecessary code like connecting to the database, but I am connected properly.
I get an error message saying:
You have an error in your SQL syntax...
How can I fix my code to delete rows from the schedule table that aren't found in the ids tuple?