【发布时间】:2017-07-27 03:46:56
【问题描述】:
我有以下 SQL 查询,它从表“my_table”中选择列“item”和“feature”,其中“item”和“other_feature”这对列与某些值对匹配。
select item, feature from my_table
where (item, other_feature) in (VALUES ('item1', 'A'), ('item1', 'B'));
Here is an example of the dataset used.
此查询在 sqlite3 命令行界面中按预期工作。但是,使用相同的数据库,当使用以下代码在 python 中使用sqlite3 模块时出现错误。
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)
我收到以下错误:
sqlite3.OperationalError: near ",": syntax error
为什么这个查询在 python sqlite3 模块中不能正常工作?
【问题讨论】: