Hello!
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))
self.db.commit()
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?
Cheers!
Dani