0

code:

 def update(self):
        if self.var_contact.get()=="":
            messagebox.showerror("Error","Contact cannot be empty",parent=self.root)
        else:    
            conn=mysql.connector.connect(host="localhost",username="root",password="krish@123",database="face_monitoring") 
            mycursor=conn.cursor()
            mycursor.execute("update room set Checkindate=%s,Checkoutdate=%s,Room type=%s,Room available=%s,Meals=%s,Duration of suite=%s where Contact=%s",(

                                                                                                                                                        
                                                                                                                                                            self.var_checkin.get(),
                                                                                                                                                            self.var_checkout.get(),
                                                                                                                                                            self.var_roomtype.get(),
                                                                                                                                                            self.var_roomavailable.get(),
                                                                                                                                                            self.var_meal.get(),
                                                                                                                                                            self.var_duration.get(),
                                                                                                                                                            self.var_contact.get()
                                                                                                                                                            
                                                                                                                                                                                 
                                                                                                                                                           ))

            conn.commit()
            self.fetch_data() 
            conn.close()
            messagebox.showinfo("Update","Room details has been updated successfully",parent=self.root)

error:

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type='Deluxe',Room available='2002',Meals='10',Duration of suite='3' where Conta' at line 1

Shadow
  • 33,525
  • 10
  • 51
  • 64
krishna
  • 1
  • 1
  • 1
    Please edit your code indentation and put code inside a pair of triple backticks `\`\`\``. Currently it's unreadable. – AcaNg Jun 12 '22 at 15:09
  • What are the names of the fields in the room table? Your code says `Room available` - should not it be `Room.available` or `\`Room available\``? And the same applicable to all field names with a space in them. – Shadow Jun 12 '22 at 15:55
  • thanks brother their was a indentation error in creation of variables – krishna Jun 13 '22 at 13:00

0 Answers0