簡體   English   中英

並非所有參數都用於 SQL 語句 - Python、MySQL

[英]Not all parameters were used in the SQL statement - Python, MySQL

我收到此代碼錯誤。 編程錯誤是語句中並未使用所有參數。 我認為這是關於更新聲明,但我不知道真正的問題是什么

定義編輯配置文件():

username1 = username_verify.get()
password1 = password_verify.get()
full_name1 = full_name_verify.get()
faculty1 = c.get()
position1 = position_verify.get()
email1 = email_verify.get()
room_no1 = room_no_verify.get()

if full_name1 == "" and faculty1 == "" and  position1 == "" and email == "" and room_no1 == "":
     Label(text="").pack()
     time.sleep(1)
     Label(text="Please complete your profile", fg="red", width=50).place(x=250,y=380)

else:
    profile_upd = "UPDATE profile SET Faculty = %s AND Position = %s AND Email = %s AND  Room_NO = %s WHERE username =%s"
    user1 = (full_name1, faculty1, position1, email1, room_no1,username1)
    mycursor.execute(profile_upd, user1)
    mydb.commit()
    Label(text ="CHANGES SAVED SUCCESFULLY!!", fg = "green",width=50).place(x=250,y=380)

追溯

該錯誤表明所需參數的數量與元組user1中的參數數量不匹配。

在元組user1中,有 6 個元素,但您的更新命令只有 5 %s 看起來您錯過了 update 命令中的full_name1

更新命令應該是這樣的:

profile_upd = "UPDATE profile SET Full_Name = %s AND Faculty = %s AND Position = %s AND Email = %s AND  Room_NO = %s WHERE username =%s"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM