![](/img/trans.png)
[英]mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; for the right syntax to use near ')' at line 1
[英]error 1064 (42000) : You have an error in your SQL syntax near to use %s
我不知道我做錯了什么,但錯誤是:error 1064 (42000): You have an error in your SQL syntax; 檢查與您的 MySQL 服務器版本相對應的手冊,以獲取在“%s”附近使用的正確語法
def forget_password_window(self):
if self.Mail_address.get()=="":
messagebox.showerror("Erreur", "Veuillez rentrer une adresse mail valide.", parent=self.app)
else:
try:
mydb = mysql.connector.connect(
host = "localhost",
user = "username",
password = "pwd",
auth_plugin='mysql_native_password',
database = "mydb"
)
cursor = mydb.cursor()
cursor.execute("""SELECT * FROM Employee WHERE employee_address=%s """,(self.Mail_address.get()))
row = cursor.fetchone()
我在我的代碼中制作了上面的代碼:
def connexion(self):
if self.Mail_address.get()=="" or self.Password.get()=="":
messagebox.showerror("Erreur", "Veuillez saisir l'adresse mail et le mot de passe !", parent=self.app)
else :
try:
mydb = mysql.connector.connect(
host = "localhost",
user = "username",
password = "pwd",
auth_plugin='mysql_native_password',
database = "mydb"
)
cursor = mydb.cursor()
cursor.execute("""SELECT * from Employee WHERE employee_address=%s and employee_matricule=%s""",(self.Mail_address.get(), self.Password.get()))
row = cursor.fetchone()
此代碼正在運行。 所以我知道為什么這段代碼有效而第一個無效。 需要幫忙 ! 謝謝 !
MySQL 連接器至少需要 2 個維度的列表作為參數
因此,將您的代碼更改為
def forget_password_window(self):
if self.Mail_address.get()=="":
messagebox.showerror("Erreur", "Veuillez rentrer une adresse mail valide.", parent=self.app)
else:
try:
mydb = mysql.connector.connect(
host = "localhost",
user = "username",
password = "pwd",
auth_plugin='mysql_native_password',
database = "mydb"
)
cursor = mydb.cursor()
cursor.execute("""SELECT * FROM Employee WHERE employee_address=%s """,(self.Mail_address.get(),))
row = cursor.fetchone()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.