我正在尝试在python上编写搜索功能,在数据库中搜索客户ID(对于登录功能),这里是代码:
def search_ID():
import sqlite3 # imports SQlite library
new_db = sqlite3.connect('LightningParties.db')
c = new_db.cursor()
c.execute("SELECT * FROM Customer_Details WHERE ID=?",(CustomerIDSave,))
results = c.fetchall # fetches all of the ID's not just one
for row in results:
forename1 = (column[1])
无论何时我尝试运行此操作,我都会收到此错误:
File "F:/stuff that actually works/customer_login.py", line 29, in search_ID
for row in results: TypeError:
'builtin_function_or_method' object is not iterable
我该如何解决这个问题?任何帮助都会很乐意接受
答案 0 :(得分:2)
尝试添加parens:
results = c.fetchall()
当您正在运行方法并分配它返回的内容时,您将分配该方法。