mysql – How can I modify three columns with one query statement python?

Question

I designed a screen consisting of three input boxes as shown in the image below:

I created a table with three columns(id,name,avg), and I want to modify a specific record by entering the value of the old student number,the new student number, the new name ,and the new student average,Then I want to use the sql python sentence to do that .How can i write sql sentence to update the three columns of student?

I am using this code:

def update_record():
oldnumberinput=TextOldNo.get()
newnumberinput=TextNewNo.get()
oldnameinput=TextOldName.get()
newnameinput=TextNewName.get()
oldavginput=TextOldAvg.get()
newavginput=TextNewAvg.get()
sql=”update studentinfo set id= “+newnumberinput,’name=”+newnameinput +” where id = ‘+oldnumberinput,’name=”+newnameinput
cursor1.execute(sql)
mydb.commit()
msg = messagebox.showinfo(“Update Record”,” Student record has been successfully updated”)

UpdateRecordButton = tk.Button(top, text =”Update”,bd=5,bg =”white’,command=update_record)
UpdateRecordButton.place(x = 90, y = 252, width = 100)
CancelUpdateRecordButton = tk.Button(top, text =”Cancel”,bd=5,bg =’white’)
CancelUpdateRecordButton.place(x = 210, y = 252, width = 100)
top.mainloop()

input screen

0
Ahmad Sarairah 1 year 2021-12-05T05:46:24-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse