Reputation: 337
q = """DELETE FROM my_table
WHERE id in ({}) (select id from ({}))""".format(list_of_ids_to_be_deleted)
Not sure how to delete rows from the table when I am given a list of indices to be deleted.
Upvotes: 0
Views: 30
Reputation: 17836
The second part of your query is not needed: just use the provided list.
q = """DELETE FROM my_table
WHERE id in ({})""".format(list_of_ids_to_be_deleted)
You might have to build a comma-separated input, similar to
q = """DELETE FROM my_table
WHERE id in ({})""".format(','.join(map(str, list_of_ids_to_be_deleted)))
Upvotes: 2