I am trying to update a MySQL table using a Python code but I am having some problems. I define the connection and the cursor in the Ornithobase (wx.Frame)class in the OnLof function as

self.db= MySQLdb.connect(host='localhost', user=self.Username , passwd=self.pwd, db='Ornithobase')
self.cursor = self.db.cursor()

Then, in the same class but in another function, I try to update a MySQL table with this statement

if dlg.ShowModal() == wx.ID_OK:
    print 'Updating'
    sql = 'UPDATE Users SET Name = %s, FamilyName = %s, eMail = %s WHERE Username = %s'
    self.cursor.execute(sql, (Name, FamilyName, eMail, CurrentUser))
    print 'Done'
    print Name
    print FamilyName
    print eMail
    print CurrentUser

The printing statements here were just to know whether the if statement was working and that the variable values were properly retrieved in the previous code. However, when I run it it neither updates the table nor it prints any error. Can anyone note if there is any mistake in the code?


Here's the output:

print response
print wx.ID_OK
print response==wx.ID_OK

If you do not get 'Updating', if not, you must not reach the if even, but problem is before the code you posted.

This article has been dead for over six months. Start a new discussion instead.