【发布时间】:2017-10-31 05:45:45
【问题描述】:
只是为了解释这里发生了什么:我有一个搜索功能,它使用用户输入 [givenLocation] 运行 MySQL 查询。它应该将查询的内容转储到列表框[self.lookuplist]。我的问题是,即使我正在使用 fetchall() 函数,它也只会转储第一个结果。我是一名自学成才的 Python 开发人员,但我无法从其他来源找到任何相关信息。这是我的代码:
def searchL_button(self):
i = 0
givenLocation = self.top3.searchEntry1.get()
searchLookup = ("SELECT Status, Serial, Product_Code, Location FROM Registers WHERE Location = %s")
cursor9.execute(searchLookup, [givenLocation])
locRes = cursor9.fetchall() [i]
for i in locRes:
self.lookupList.insert(END, locRes)
【问题讨论】:
标签: python mysql loops tkinter listbox