【发布时间】:2020-05-14 17:27:00
【问题描述】:
我是 Python 新手。 我遇到了 Tkinter 和 Sqlite 的问题。我需要从“查找单词”框中的输入中获取数据库中的特定单词。
#create function to search a record
def wordSearch():
conn = sqlite3.connect('mydata.db')
c = conn.cursor()
c.execute("SELECT * FROM information WHERE my_word = ?")
记录 = c.fetchall() 打印(记录)
#Loop thru results
print_records = ''
for record in records:
print_records += str(record[0]) + " "+ str(record[1]) + " " + str(record[2])+'\n'
conn.commit()
conn.close()
#create text boxes
wordSearch_entry = Entry(root, width = 30)
wordSearch_entry.grid(row = 5, column = 1, pady = 5 )
#create text box labels
wordSearch_entry_label = Label(root, text = "Find word")
wordSearch_entry_label.grid(row = 5, column = 0, pady = 5)
btn_wordSearch = Button(root, text="Search word", command=wordSearch)
btn_wordSearch.grid(row = 6, column = 0, columnspan = 2, pady = 10, ipadx = 130)
【问题讨论】:
-
您没有为查询提供参数。