“builtin_function_or_method”对象有没有属性“执行”的cursor.ececute(声明)
问题描述:
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)
当执行上面的代码给出了一个错误的东西像“builtin_function_or_method”对象有没有属性“执行”的cursor.ececute(声明)
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
是一种方法,如果你不调用它,你会得到方法对象本身,而不是调用它的结果。督察,你想要的是
cursor = c.cursor()
+0
谢谢你,我忽略了! –
你需要调用'光标= c.cursor()' – PRMoureu
你试过 'c.cursor.execute(select_statement中)'? –
@MuhammadAsif你读过db-api文档吗? –