【发布时间】:2011-03-07 12:32:58
【问题描述】:
我正在尝试将参数化的 LIKE 查询与 Python 的 Sqlite 库一起使用,如下所示:
self.cursor.execute("select string from stringtable where string like '%?%' and type = ?", (searchstr,type))
但是 ?通配符内部没有被评估,留下这个错误:
"sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 2 supplied."
我还尝试使用标记版本的查询:
like '%:searchstr%' 并在具有{"searchstr":searchstr... 的列表中
但是当我这样做时,查询会运行,但即使手动输入 "like '%a%'"... 会返回数百个结果,也不会返回任何结果
有什么建议吗?
【问题讨论】: