I want to delete all records in mysql db except the record identifier that I have in the list. The length of this list can vary and can easily contain 2000+ id, ...
I am currently converting my list to a string so that it fits into something like this: cursor.execute ("" remove from the table where id is not in (% s) "" ", (list)) Which does not seem to be correct , and I have no idea how long the list is resolved, ....
What is the most efficient way to do this from python?
Changing the structure of the table with an additional field for marking / unchecking for deletion would be great, but not an option. If a dedicated table storing an identifier would really be useful, then this can only be done using an SQL query ... but I would really like to avoid these parameters, if possible.
Thank,
jay_t source
share