在Python中使用简单的sqlite查询时令人困惑的AttributeError

2024-09-26 18:18:27 发布

您现在位置:Python中文网/ 问答频道 /正文

当我调用python中的一个函数来执行查询时,我遇到了一个错误,这使我感到困惑和沮丧。我已经检查,以确保我没有制表符,而不是间隔缩进(检查模糊)。我遵循了这里使用的约定:http://zetcode.com/db/sqlitepythontutorial/和这里:How to check the existence of a row in SQLite with Python?

有人能理解为什么这个看起来不错的代码会抛出一个错误吗?我现在是码盲。谢谢!在

错误:

File "paddle-csv-import.py", line 23, in getscore
cur1.execute("SELECT pts FROM matchpoints WHERE s1 =? and s2 = ? and \
AttributeError: 'builtin_function_or_method' object has no attribute 'execute' 

相关代码:

^{pr2}$

此函数稍后从循环中调用,并且正在正确传递数据。我在函数中插入了一条打印线,以确保数据被正确地传递,然后得到了这个,这是正确的。在

('3-6', '1-6', '0-0') 

我在sqlite中直接在同一个数据库上运行相同的、精确的查询,结果如预期般返回。在


Tags: andto函数代码incomhttpexecute

热门问题