Here is how the code looks like. "vare" is the section i want to update
def update():
sqlCon = pymysql.connect(host = "localhost", user = "root", password = "root", database = "varehusdb")
cur =sqlCon.cursor()
cur.execute("update vare set Betegnelse=%s, Pris=%s, KatNr=%s, Antall=%s, Hylle=%s where VNr=%s",(
Betegnelse.get(),
Pris.get(),
KatNr.get(),
Antall.get(),
Hylle.get(),
VNr.get(),
))
sqlCon.commit()
sqlCon.close()
tkinter.messagebox.showinfo("Data Entry Form", "Record Updated Successfully")
edit: Thx!
I based this from this tutorial i saw on youtube https://youtu.be/dxOPaIX4qt4?feature=shared
Which is a very useful video. I got it all to work, exit, add data, info, reset.. and while i had to use a trick to make "Display" work, overall worked very well.
But everytime i try to run this normally, and press the "Update" button for the str i want to change. It says it went successfully... without anything happening. Same thing happens if i press "Delete" button. And if i try to search for a value... it just says "No such record found". Which is usually means it couldnt find that value you were typing in.
So what am i doing wrong with these three functions?
To make it work with the Display function i used this tutorial in the Visual Studio https://youtu.be/tnlGr1LeZDs?feature=shared Which worked. But for Update, Delete and Search function, i am totally clueless on.
edit cur.commit() did the trick. THANKS! I dont think it works for Delete or Search function. But its better than nothing and works well for update function. Much appreciated!
it's essential to ensure that the values you're trying to update with (Betegnelse, Pris, KatNr, Antall, Hylle, VNr) have the correct values at the time of execution. You may print these values before the update statement to debug: