我使用 python 和 SQL 为客户帐户创建数据库。我正在尝试提供更新客户详细信息的选项。我已经完成了我认为会更新表格的操作,但是当我打印内容时,什么都没有改变。请你能告诉我哪里出错了吗?
def update_Customer(self):
# create sqlite connection
conn = sqlite3.connect("lanyard.db", timeout=5)
c = conn.cursor()
# if texfield is empty
if self.TextField1.get() !="":
if self.TextField2.get() != "":
nameChange1 = self.TextField2.get()
CusNo = self.TextField1.get()
c.execute("""
UPDATE customer
SET first_name = 'nameChange1'
WHERE customer_id = 'CusNo'""")
conn.commit()
if self.TextField3.get() != "":
nameChange2 = self.TextField3.get()
CusNo = self.TextField1.get()
c.execute("""
UPDATE CUSTOMER
SET second_name = 'nameChange2'
WHERE customer_id = 'CusNo'""")
conn.commit()
if self.TextField4.get() == "":
nameChange3 = self.TextField4.get()
CusNo = self.TextField1.get()
c.execute("""
UPDATE CUSTOMER
SET address = 'nameChange3'
WHERE customer_id = 'CusNo'""")
conn.commit()
conn.commit()
c.close()
# clear input
self.TextField1.delete(0, END)
self.TextField2.delete(0, END)
self.TextField3.delete(0, END)
self.TextField4.delete(0, END)