'builtin_function_or_method'对象的cursor.ececute(statement)没有属性'execute' [英] 'builtin_function_or_method' object has no attribute 'execute' for cursor.ececute(statement)
本文介绍了'builtin_function_or_method'对象的cursor.ececute(statement)没有属性'execute'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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)
上面的代码在执行时会给出类似错误
The code above when executed gives an error something like
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执行此查询?
I am new to using python sqlite3 so how do I execute this query with sqlite3 in python?
推荐答案
Connection.cursor
是一个方法,如果不调用它,则得到方法对象本身,而不是调用它的结果。 IOW,您想要的是
Connection.cursor
is a method, if you don't call it you get the method object itself, not the result of calling it. IOW, what you want is
cursor = c.cursor()
这篇关于'builtin_function_or_method'对象的cursor.ececute(statement)没有属性'execute'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文