#""""""""""""" UPDATE FUNCTION """"""""""
def update_data(self):
if self.var_dep.get()=="Select Department" or self.var_std_name.get()=="" or self.var_std_id.get()=="":
messagebox.showerror("Error","All Fields are required",parent=self.root)
else:
try:
update=messagebox.askyesno("Update","Do you want to update this student details",parent=self.root)
if update>0:
conn=mysql.connector.connect(host="localhost", username="root", password="Umer@123", database="face_recognizer")
my_cursor=conn.cursor()
my_cursor.execute("update student set Dep=%s,course=%s,Year=%s,Semester=%s,Division=%s,Roll=%s,Gender=%s,Dob=%s,Email=%s,Phone=%s,Address=%s,Teacher=%s,PhotoSample=%s where Student_id=%s",(
self.var_dep.get(),
self.var_course.get(),
self.var_year.get(),
self.var_semester.get(),
self.var_std_name.get(),
self.var_div.get(),
self.var_roll.get(),
self.var_gender.get(),
self.var_dob.get(),
self.var_email.get(),
self.var_phone.get(),
self.var_address.get(),
self.var_teacher.get(),
self.var_radio1.get(),
self.var_std_id.get()
))
else:
if not update:
return
conn.commit()
self.fetch_data()
conn.close()
messagebox.showinfo("Sucess","Student details successfully update completed",parent=self.root)
except Exception as es:
messagebox.showerror("Error",f"Due To:{str(es)}",parent=self.root)
字符串
我找不到错误。
1条答案
按热度按时间kxeu7u2r1#
对不起,先生,但你的代码真的很可怕....
也许可以稍微解耦一下
字符串
你可以看到args中变量的数量与查询所期望的数量不同。
但不管怎样,这些事情不是这样做的,如果有一天你决定增加或减少字段的数量,你会怎么做?