【发布时间】:2021-04-14 10:00:06
【问题描述】:
我目前正在为学校做一个课程项目,它是一个带有使用 Tkinter、Python 和 SQLite3 的用户界面的数据库系统。我已经制作了一个表格来添加、删除、更新和搜索客户。更新功能不会产生任何错误,但是,不会对 .db 文件进行更改。任何人都可以看看,也许可以告诉我哪里出错了?我将附上用户界面的照片和功能的代码。我不习惯使用 StackOverflow,所以如果我遗漏了任何内容或者您需要更多信息,请告诉我。提前谢谢你。
def UpdateCustomer(self):
customerid = self.CustomerEntry.get();
town = self.TownEntry.get();
postcode = self.PostcodeEntry.get();
with sqlite3.connect("LeeOpt.db") as db:
cursor = db.cursor()
update_customer = ('''UPDATE Customer
SET
Town = ?,
Postcode = ?
WHERE CustomerID = ?
''')
db.commit()
cursor.execute(update_customer,[(customerid),(town),(postcode)])
tkinter.messagebox.showinfo("Notification","Customer record updated successfully")
self.ClearEntries()
【问题讨论】:
标签: python database sqlite tkinter