我需要删除所有值都匹配的SQLite数据库中的条目。
所以我创建这样的条目:
# Insert a row of data
c.execute("insert into Database (Value1, Value2, Value3, Value4, Value5, Value6) values (?, ?, ?, ?, ?, ?)",
(d1, d2, d3, d4, d5, d6))
然后,我将通过其值删除确切的条目。我这样尝试过:
c.execute("delete from Database where (Value1, Value2, Value3, Value4, Value5, Value6) values (?, ?, ?, ?, ?, ?)",
("String1", "String2", "String3", "String4", "String5", "String6"))
但是我明白了:OperationalError: near "values": syntax error
如何删除具有多个匹配值的SQLite条目?
答案 0 :(得分:1)
您必须编写完整的SQL条件:
c.execute('delete from Database where Value1=? and Value2=? and Value3=? and Value4=? and Value5=? and Value6=?', ("String1", "String2", "String3", "String4", "String5", "String6"))
您可以学习完整的语法here。