'builtin_function_or_method' 对象没有属性 'execute' 用于 cursor.ececute(声明)
'builtin_function_or_method' object has no attribute 'execute' for cursor.ececute(statement)
c = sqlite3.connect(history_db)
cursor = c.cursor
select_statement = "SELECT urls.urls,urls.Visit_count FROM urls,Visits WHERE
urls.id=visits.urls;"
cursor.execute(select_statement)
results = c.cursor.fetchcall()
print(results)
上面的代码在执行时给出类似
的错误
Traceback (most recent call last):
File "test.py", line 13, in <module>
cursor.execute(select_statement)
AttributeError: 'builtin_function_or_method' object has no attribute
'execute'
我是 python sqlite3 的新手,所以如何在 python 中使用 sqlite3 执行此查询?
Connection.cursor
是一个方法,如果你不调用它,你得到的是方法对象本身,而不是调用它的结果。 IOW,你要的是
cursor = c.cursor()
c = sqlite3.connect(history_db)
cursor = c.cursor
select_statement = "SELECT urls.urls,urls.Visit_count FROM urls,Visits WHERE
urls.id=visits.urls;"
cursor.execute(select_statement)
results = c.cursor.fetchcall()
print(results)
上面的代码在执行时给出类似
的错误Traceback (most recent call last):
File "test.py", line 13, in <module>
cursor.execute(select_statement)
AttributeError: 'builtin_function_or_method' object has no attribute
'execute'
我是 python sqlite3 的新手,所以如何在 python 中使用 sqlite3 执行此查询?
Connection.cursor
是一个方法,如果你不调用它,你得到的是方法对象本身,而不是调用它的结果。 IOW,你要的是
cursor = c.cursor()