当我把变数输入“名称:植被(a)变数”时,我预计会从b中的配量回来。 这样,用户就能够确定在数据集中是否有人。
在我进行搜查时(从TKinterGUI),我有以下错误:
*line 35, in search
c.execute("SELECT * FROM addresses WHERE last_name=" + l_name.get())
sqlite3.OperationalError: no such column: Mustang*
(Mustang是搜索词)
这是在Kalk3号文件中提出的表格:
c.execute(""" CREATE TABLE addresses (
first_name text,
last_name text,
address text,
city text,
state text,
postcode integer)""")
职能如下:
def search():
#connect to database from within function
conn = sqlite3.Connection( address_book.db )
#create a cursor from within function
c = conn.cursor()
#Search function in SQL
c.execute("SELECT * FROM addresses WHERE last_name=" + l_name.get())
records = c.fetchall()
print_records=""
#this loop will print selected items
for record in records:
print_records += str(record[0])+ " " + str(record[1]) + " " + str(record[2]) + "
"
#commit changes
conn.commit()
#close connection
conn.close()
#clear text boxes
#query lbl part of the function to display results
query_lbl=Label(root, text=print_records)
query_lbl.grid(row=15,column=0, columnspan=2)
I have tested the variable and it is functioning, I have been able to search by oid with the same code, replacing "last_name" with "oid". I am at a loss. (also quite new to this so please be gentle)