[英]SQLite3 incorrect number of bindings on second query
使用 Python 和 SQlite3 ,其中 c 是 cursor 这个代码......
print("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
print("SQL and parameters:",sql,parm)
c.execute(sql,parm)
# Get the row
print("Executed OK")
response = c.fetchone()
# If not successful return null
if not response:
return None
#
print("and produced ", response)
print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
给这个 output:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
SQL and parameters: select * from Links where LinkNum = ? (301,)
Executed OK
and produced (301, 'Index', 'The Independent', 'https://www.independent.co.uk/', 6, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
SQL and parameters: select * from Links where LinkNum = ? (301,)
Encountered exception of type ProgrammingError with arguments ('Incorrect number of bindings supplied. The current statement uses 1, and there are 6 supplied.',)
The application will close
两个相同的说法。 1 工作,下一个抛出异常。 可以看出我要检索的行有 6 列,但这是我能看到的唯一提示/线索。 任何人都可以帮助追踪问题吗? 谢谢。
无论是什么导致 SQLite 适应,我通过在链接 object 之外检索第二行/对象并将其作为参数传递给我正在调用的方法来解决问题,而不是让该方法尝试检索 ZA8CFDE8931BD59B66696C4C。
问题仍然存在,但必须深入 Python 实例化和/或 SQLite 的内部。 不管怎样,这个问题可以用一些不太花哨的代码来解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.