K-Doe
K-Doe

Reputation: 559

Python SQLite Delete From Where multiple values match

I need to delete entries in my SQLite DB where all Values match.

So I create the entry like that:

    # Insert a row of data
    c.execute("insert into Database (Value1, Value2, Value3, Value4, Value5, Value6) values (?, ?, ?, ?, ?, ?)",
            (d1, d2, d3, d4, d5, d6))

And later on i will delete the exact entry by its values. I tried it like that:

    c.execute("delete from Database where (Value1, Value2, Value3, Value4, Value5, Value6) values (?, ?, ?, ?, ?, ?)",
            ("String1", "String2", "String3", "String4", "String5", "String6"))

But i get this: OperationalError: near "values": syntax error

How do I delete a SQLite entry with multiple values matching?

Upvotes: 0

Views: 1219

Answers (1)

rene-d
rene-d

Reputation: 343

You have to write the full SQL condition:

c.execute('delete from Database where Value1=? and Value2=? and Value3=? and Value4=? and Value5=? and Value6=?',  ("String1", "String2", "String3", "String4", "String5", "String6"))

You can learn the full syntax here.

Upvotes: 2

Related Questions