Python没有';t向上桌

Python没有';t向上桌,python,mysql,tkinter,Python,Mysql,Tkinter,我试图用Python做数据库GUI应用程序,但我不能更新表。并没有错误,但我运行程序后,我看Mysql工作台并没有任何变化 class DB: def __init__(self): self.conn = mysql.connector.connect(host='localhost', database='databese', user='user',

我试图用Python做数据库GUI应用程序,但我不能更新表。并没有错误,但我运行程序后,我看Mysql工作台并没有任何变化

class DB:
    def __init__(self):
        self.conn = mysql.connector.connect(host='localhost',                                                   database='databese', user='user',                                              
         password='password')
        self.cur = self.conn.cursor()
        self.conn.commit()

    def update(self, isim):
        self.conn.commit()
        self.cur.execute("UPDATE hakemler SET durum='UYGUNSUZ' WHERE isim='%s' ",isim)

    def updateback(self, isim):
        self.cur.execute("UPDATE hakemler SET durum='UYGUN' WHERE isim='%s'",isim)
        self.conn.commit()
db = DB()

def çıkar():
    db.update(id.get())
def gerial():
    db.updateback(hakem1.get())
hakem = StringVar()
hakem1= StringVar()
id  = IntVar()
entry1 = tk.Entry(mazeretli, width=20, textvariable=id)
entry1.grid(row=1, column=1)
button1 = tk.Button(mazeretli, text="Kişiyi Listeden Çıkar", command=çıkar)
button1.grid(row=2, column=2)
entry2 = tk.Entry(mazeretli, width=20, textvariable=hakem1)
entry2.grid(row=3, column=1)
button2 = tk.Button(mazeretli, text="Kişiyi Geri Al", command=gerial)
button2.grid(row=4, column=2)
没有错误,没有错误,没有错误。代码不起作用

您的问题在于:

def update(self, isim):
    self.conn.commit()
    self.cur.execute("UPDATE hakemler SET durum='UYGUNSUZ' WHERE isim='%s' ",isim)
数据库操作要求您在操作后提交,以便将更改写入数据库。你的顺序颠倒了。替换订单:

def update(self, isim):
    self.cur.execute("UPDATE hakemler SET durum='UYGUNSUZ' WHERE isim='%s' ",isim)
    self.conn.commit()

我试过了,在这个例子中,函数updateback就像你说的那样