'How do I fix the 'not all parameters were used' error in this Python program with MySQL connectivity?

*I'm trying to make a login/sign up page using a Python MySQL connector and tkinter. I'm constantly getting an error for the parameters. For the sign up part, I've set a default value for the username as primary keys require one, but when I run the code, it says "duplicate entry for key".

Also, here are all the errors I've gotten:

×Not all parameters were used ×Could not process parameters ×Python type tuple cannot be converted ×'tuple' object has no attribute 'encode' ×Lost connection to MySQL server at 'localhost:3306', system error: Connection not available. I've attached the condensed version of the code.

from tkinter import *
import mysql.connector
co=mysql.connector.connect(host="localhost",user="root",password="riptide",buffered=True)
c=co.cursor()

notelogin=('floor','noteroomnum','notefrom','noteto','noteluname')
loginsert="update guests set floor=(?),numberof_rooms=(?),departuresite=(?),destination=(?) where username=(?)"


c.execute("use studio")
c.execute("SET GLOBAL connect_timeout = 1200")
c.execute(loginsert,(notelogin,))
co.commit()

if  (co.is_connected()):
    c.close()
    co.close()

for i in c:
    print(i)

t.mainloop()

*main code: *

from tkinter import *
import mysql.connector
co=mysql.connector.connect(host="localhost",user="root",password="riptide",buffered=True)
c=co.cursor()

fromvalues=["Abu Dhabi","Dubai","Sharjah","Fujairah","Umm Al Quwain","Ras Al Khaimah","Ajman","Amsterdam","New York","Tokyo","Bern","Chicago","Istanbul","Ankara","Baku","Qabala",
            "Delhi","Chennai","Thiruvananthapuram","Kollam","Seoul","Busan","Daegu","Paris","London","Winchester","Dublin","Rome","Madrid","Moscow","Montreal","Sydney","Singapore",
            "Berlin","Miami","Shanghai","Toronto","Melbourne","Copenhagen","Milan","Prague","Zeytinburnu","Zurich"]
tovalues=["Abu Dhabi","Dubai","Sharjah","Fujairah","Umm Al Quwain","Ras Al Khaimah","Ajman","Amsterdam","New York","Tokyo","Bern","Chicago","Istanbul","Ankara","Baku","Qabala",
            "Delhi","Chennai","Thiruvananthapuram","Kollam","Seoul","Busan","Daegu","Paris","London","Winchester","Dublin","Rome","Madrid","Moscow","Montreal","Sydney","Singapore",
            "Berlin","Miami","Shanghai","Toronto","Melbourne","Copenhagen","Milan","Prague","Zeytinburnu","Zurich"]
dates=['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31']
months=["January","February","March","April","May","June","July","August","September","October","November","December"]
years=['2022','2023','2024','2025','2026','2027','2028','2029','2030']
roomvalues=["first floor, one bedroom, 300 per night","second floor, one bedroom, 350 per night","third floor, two bedrooms, 400 per night",
            "fourth floor, two bedrooms, 450 per night","fifth floor, suite, 550 per night"]
roomnumvalues=[1,2,3,4,5,6,7]
prefrom=["departure:"]
preto=["arrival:"]
predates=["date:"]
premonths=["month:"]
preyears=["year:"]
preroom=["desired room:"]
preroomnum=[1]
    

def login():
    l=Toplevel()
    l.title("")
    l.geometry("500x650")
    l.configure(background="#232023")
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    
    Label(l,width=40,text="first name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    lfname=Entry(l,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    lfname.pack()
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(l,width=40,text="last name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    llname=Entry(l,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    llname.pack()
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(l,width=40,text="username [enter your national ID card number]:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    luname=Entry(l,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    luname.pack()
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(l,width=40,text="password:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    lpass=Entry(l,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    lpass.pack()
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(l,width=40,text="credit card number:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    lcred=Entry(l,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    lcred.pack()
    Label(l,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()

    
    def prepostlogin():
        nonlocal lfname
        nonlocal llname
        nonlocal luname
        nonlocal lpass
        nonlocal lcred
        
        notelfname=lfname.get()
        notellname=llname.get()
        noteluname=luname.get()
        notelpass=lpass.get()
        notelcred=lcred.get()
        if notelfname=="" or notellname=="" or noteluname=="" or notelpass=="" or notelcred=="":
            Label(l,text="please don't leave any field empty",width=40,bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
        else:
            Label(l,text="",width=40,bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal")).pack()

        def postlogin():
            roomvalues=["first floor, one bedroom, 300 per night","second floor, one bedroom, 350 per night","third floor, two bedrooms, 400 per night",
                        "fourth floor, two bedrooms, 450 per night","fifth floor, suite, 550 per night"]
            roomnumvalues=[1,2,3,4,5,6,7]
            preroom=["desired room:"]
            preroomnum=[1]
            Label(l,text="log in successful",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
            Label(l,text="finish booking:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
            roomclicked=StringVar()
            roomnumclicked=IntVar()
            roomclicked.set(preroom[0])
            roomnumclicked.set(preroomnum[0])
    
            droproom=OptionMenu(l,roomclicked,*roomvalues)
            droproom.configure(width=45,bg="#232023",fg="#C3B091")
            droproom.pack()
            Label(l,text="number of rooms:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack
            droproomnum=OptionMenu(l,roomnumclicked,*roomnumvalues)
            droproomnum.configure(width=45,bg="#232023",fg="#C3B091")
            droproomnum.pack()

            noteroom=roomclicked.get()
            noteroomnum=roomnumclicked.get()
            
            def booked():
                b=Toplevel()
                b.title("")
                b.geometry("500x550")
                b.configure(background="#232023")
                floor=""

                nonlocal noteroom
                nonlocal noteroomnum
                nonlocal luname
                global notefrom
                global noteto
    
                if noteroom==roomvalues[0]:
                    floor+="first floor"
                elif noteroom==roomvalues[1]:
                    floor+="second floor"
                elif noteroom==roomvalues[2]:
                    floor+="third floor"
                elif noteroom==roomvalues[3]:
                    floor+="fourth floor"
                elif noteroom==roomvalues[4]:
                    floor+="fifth floor"
    
                notelogin=(floor,noteroomnum,notefrom,noteto,noteluname,)
                loginsert="update guests set floor=(?),numberof_rooms=(?),departuresite=(?),destination=(?) where username=(?)"
                noteinsert=(loginsert,(notelogin))
        
                if noteroom=="" or noteroomnum=="":
                    Label(b,text="Please don't leave any field empty",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
                else:
                    c.execute("use studio")
                    c.execute("SET GLOBAL connect_timeout = 1200")
                    c.execute(noteinsert)
                    co.commit()
                    Label(b,text="trip booked successfully",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
                    Label(b,text="see you soon",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal")).pack()

                def ldetails():
                    Label(b,width=50,text="ticket details:",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","17","normal")).pack()
                    Label(b,width=50,text="name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="from:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="to:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="date:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="floor:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="number of rooms:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                
                Button(b,text="view details",bg="#C3B091",fg="#232023",height="1",width="14",font=("bookman old style","12","normal"),command=ldetails).pack()
            Button(l,text="done",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal"),command=booked).pack()
        Button(l,text="continue",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=postlogin).pack()
    Button(l,text="continue",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=prepostlogin).pack()

def signup():
    s=Toplevel()
    s.title("")
    s.geometry("500x650")
    s.configure(background="#232023")
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    
    Label(s,width=40,text="first name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    sfname=Entry(s,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    sfname.pack()
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(s,width=40,text="last name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    slname=Entry(s,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    slname.pack()
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(s,width=40,text="username [enter your national ID card number]:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    suname=Entry(s,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    suname.pack()
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(s,width=40,text="password:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    spass=Entry(s,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    spass.pack()
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    Label(s,width=40,text="credit card number:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    scred=Entry(s,bg="#C3B091",fg="#232023",width=40,bd=1,font=("bookman old style","12","normal"))
    scred.pack()
    Label(s,text="",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
    
    def prepostsignup():
        nonlocal sfname
        nonlocal slname
        nonlocal suname
        nonlocal spass
        nonlocal scred
        
        notesfname=sfname.get()
        noteslname=slname.get()
        notesuname=suname.get()
        notespass=spass.get()
        notescred=scred.get()
        notesignup=(notesfname,noteslname,notesuname,notespass,notescred)
        signinsert="insert into guests(firstname,lastname,username,password,creditcard) values(%s,%s,%s,%s,%s)"
    
        if notesfname=="" or noteslname=="" or notesuname=="" or notespass=="" or notescred=="":
            Label(s,text="please don't leave any field empty",width=40,bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
        else:
            c.execute("use studio")
            c.execute(signinsert,notesignup)
            co.commit()
            Label(s,text="account created successfully",width=40,bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal")).pack()
            Label(s,text="",width=40,bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal")).pack()

        def postsignup():
            Label(s,text="finish booking:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
            roomclicked=StringVar()
            roomnumclicked=IntVar()
            roomclicked.set(preroom[0])
            roomnumclicked.set(preroomnum[0])
            noteroom=roomclicked.get()
            noteroomnum=roomnumclicked.get()
    
            droproom=OptionMenu(s,roomclicked,*roomvalues)
            droproom.configure(width=45,bg="#232023",fg="#C3B091")
            droproom.pack()
            droproomnum=OptionMenu(s,roomnumclicked,*roomnumvalues)
            droproomnum.configure(width=45,bg="#232023",fg="#C3B091")
            droproomnum.pack()

            def booked():
                b=Toplevel()
                b.title("")
                b.geometry("500x550")
                b.configure(background="#232023")
                floor=""

                nonlocal noteroom
                nonlocal noteroomnum
    
                if noteroom==roomvalues[0]:
                    floor+="first floor"
                elif noteroom==roomvalues[1]:
                    floor+="second floor"
                elif noteroom==roomvalues[2]:
                    floor+="third floor"
                elif noteroom==roomvalues[3]:
                    floor+="fourth floor"
                elif noteroom==roomvalues[4]:
                    floor+="fifth floor"
    
                notelogin=(floor,noteroomnum)
                loginsert="insert into guests(floor,numberof_rooms) values(%s,%s)"
        
                if noteroom=="" or noteroomnum=="":
                    Label(b,text="Please don't leave any field empty",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
                else:
                    c.execute("use studio")
                    c.execute(loginsert,notelogin)
                    c.execute("insert into guests(departuresite,destination) values(%s,%s)",notefromto)
                    co.commit()
                    Label(b,text="trip booked successfully",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","12","normal")).pack()
                    Label(b,text="see you soon",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal")).pack()
                def details():
                    Label(b,width=50,text="ticket details:",bg="#C3B091",fg="#232023",anchor="center",font=("bookman old style","17","normal")).pack()
                    Label(b,width=50,text="name:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="from:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="to:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="date:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="floor:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    Label(b,width=50,text="number of rooms:",bg="#232023",fg="#C3B091",anchor="nw",font=("bookman old style","12","normal")).pack()
                    
                Button(b,text="view details",bg="#C3B091",fg="#232023",height="1",width="14",font=("bookman old style","12","normal"),command=details).pack()
            Button(s,text="done",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","12","normal"),command=booked).pack()      
        Button(s,text="next",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=postsignup).pack()
    Button(s,text="continue",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=prepostsignup).pack()

def toproceed():
    Label(w,width=100,text="to proceed, log in",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","20","normal")).pack()
    Label(w,width=100,text="or create an account",bg="#232023",fg="#C3B091",anchor="center",font=("bookman old style","20","normal")).pack()
    Label(w,text="",bg="#232023",height=1,font=("bookman old style",13)).pack()
    Button(w,text="log in",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=login).pack()
    Label(w,text="",bg="#232023",height=1,font=("bookman old style",13)).pack()
    Button(w,text="sign up",bg="#232023",fg="#C3B091",height="1",width="14",font=("bookman old style",13),command=signup).pack()


w=Tk()
w.title("")
w.geometry("1920x1070")
w.configure(background="#232023")
Label(w,width=90,text="pelagia voyages",bg="#C3B091",fg="#232023",anchor="center",
      font=("bookman old style","48","normal")).pack()
Label(w,width=50,text="since 1973",bg="#232023",fg="#C3B091",anchor="e",
      font=("bookman old style","13","italic")).pack()
Label(w,text="",bg="#232023",fg="#C3B091",
      font=("bookman old style","30","normal")).pack()
Label(w,width=70,text="view trips",bg="#232023",fg="#C3B091",anchor="nw",
      font=("bookman old style","21","normal")).pack()
Label(w,text="from:",bg="#232023",fg="#C3B091",anchor="w",
      font=("bookman old style","15","normal")).pack()
fromclicked=StringVar()
fromclicked.set(prefrom[0])
dropdown_from=OptionMenu(w,fromclicked,*fromvalues)
dropdown_from.configure(width=20,bg="#232023",fg="#C3B091")
dropdown_from.pack()
Label(w,text="to:",bg="#232023",fg="#C3B091",anchor="w",
      font=("bookman old style","15","normal")).pack()
toclicked=StringVar()
toclicked.set(preto[0])
dropdown_to=OptionMenu(w,toclicked,*tovalues)
dropdown_to.configure(width=20,bg="#232023",fg="#C3B091")
dropdown_to.pack()
Label(w,text="when:",bg="#232023",fg="#C3B091",anchor="w",
      font=("bookman old style","15","normal")).pack()
dateclicked=StringVar()
monthclicked=StringVar()
yearclicked=StringVar()
dateclicked.set(predates[0])
monthclicked.set(premonths[0])
yearclicked.set(preyears[0])
dropdown_dates=OptionMenu(w,dateclicked,*dates)
dropdown_dates.configure(width=20,bg="#232023",fg="#C3B091")
dropdown_dates.pack()
dropdown_months=OptionMenu(w,monthclicked,*months)
dropdown_months.configure(width=20,bg="#232023",fg="#C3B091")
dropdown_months.pack()
dropdown_years=OptionMenu(w,yearclicked,*years)
dropdown_years.configure(width=20,bg="#232023",fg="#C3B091")
dropdown_years.pack()

notefrom=fromclicked.get()
noteto=toclicked.get()
notedate=dateclicked.get()
notemonth=monthclicked.get()
noteyear=yearclicked.get()
notefromto=(notefrom,noteto)

Label(w,text="",bg="#232023",fg="#C3B091",font=("bookman old style","5","normal")).pack()

Button(text="book",bg="#C3B091",fg="#232023",height="1",width="14",font=("bookman old style",13),command=toproceed).pack()

w.mainloop()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source