I have the following SQL query that selects the column 'item' and 'feature' from the table 'my_table' where the pair of columns 'item' and 'other_feature' match some pair of values.
select item, feature from my_table
where (item, other_feature) in (VALUES ('item1', 'A'), ('item1', 'B'));
Here is an example of the dataset used.
This query works as expected in the sqlite3 command line interface. However, using the same database, when using the sqlite3
module in python using the following code I get an error.
import sqlite3
query = "select item, feature from my_table where (item, other_feature) in (VALUES ('item1', 'A'), ('item1', 'B'))"
conn = sqlite3.connect("data/my_database.db")
conn.execute(query)
I obtain the following error:
sqlite3.OperationalError: near ",": syntax error
Why is this query not working as expected with the python sqlite3 module?