【发布时间】:2021-06-23 15:56:13
【问题描述】:
嗨 我正在尝试根据带有通配符的用户输入来搜索 SQlite 表。我尝试了不同的方法,但我无法让它工作。 这是我尝试的最后一件事,它实际上是我在这里找到的解决方案,但它可能在 python 3 中发生了变化。
search = input("type name or partial name: ")
cur.execute("select * from contacts where name like ?",
('%'+search+'%'))
这会在最后一行产生这个错误。
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 5 supplied.
我尝试了很多不同的东西,这让我发疯。我开始认为如果不先将整个表读取为字符串,这是不可能的。
【问题讨论】: