q = """DELETE FROM my_table
WHERE id in ({}) (select id from ({}))""".format(list_of_ids_to_be_deleted)
当获得要删除的索引列表时,不确定如何从表中删除行。
答案 0 :(得分:2)
不需要查询的第二部分:只需使用提供的列表即可。
q = """DELETE FROM my_table
WHERE id in ({})""".format(list_of_ids_to_be_deleted)
您可能需要构建逗号分隔的输入,类似于
q = """DELETE FROM my_table
WHERE id in ({})""".format(','.join(map(str, list_of_ids_to_be_deleted)))