0
 def add(self):
        myconn = mysql.connector.connect(host = "localhost", user = "root",passwd = "110277", database = "ims")
        cur=myconn.cursor()
        try:
            if self.var_emp_id.get()=='':
                messagebox.showerror('Error','Employee ID Must be required',parent=self.root)
            else:
                cur.execute('SELECT * FROM employee WHERE eid=?',(self.var_emp_id.get(),))
                row=cur.fetchone()
                if  row!=None:
                    messagebox.showerror("Error","This Employee ID already assigned, try different",parent=self.root )
                else:
                    add_user= ('INSERT INTO employee (eid,name,email,gender,contact,dob,doj,pass,utype,address,salary) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',(     
                                
                                self.var_emp_id.get(),
                                self.var_name.get(),
                                self.var_email.get(),
                                self.var_gender.get(),
                                self.var_contact.get(),
                                self.var_dob.get(),
                                self.var_doj.get(),
                                self.var_pass.get(),
                                self.var_utype.get(),
                                self.txt_address.get('1.0',END),
                                self.var_salary.get(),
                    ))
                             
                    myconn.commit()
                    messagebox.showinfo("Success","Employee Add Successfully",parent=self.root) 
        except Exception as ex:
            messagebox.showerror("Error",f"Error due  to: {str(ex)}",parent=self.root)


Error message:

mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
2
  • 1
    It looks like this line has a extra comma, the number of expected parameter is only one. cur.execute('SELECT * FROM employee WHERE eid=?',(self.var_emp_id.get(),)) Commented Sep 13, 2021 at 6:40
  • 3
    @ArpitChinmay, the extra comma makes it a tuple, it's needed. Commented Sep 13, 2021 at 6:56

1 Answer 1

3

Your password argument is named incorrectly

This:

myconn = mysql.connector.connect(host = "localhost", user = "root",passwd = "110277", database = "ims")

Should be:

myconn = mysql.connector.connect(host = "localhost", user = "root",password = "110277", database = "ims")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.