Python中的SQLite删除多个值匹配

问题描述 投票:0回答:1

我要删除我的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记录?

python sqlite
1个回答
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

© www.soinside.com 2019 - 2024. All rights reserved.