[英]error 1064 (42000) : You have an error in your SQL syntax near to use %s
I dont know what I done wrong, but the error is: error 1064 (42000): You have an error in your SQL syntax;我不知道我做错了什么,但错误是:error 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 '%s'
检查与您的 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()
I made this code above in my code:我在我的代码中制作了上面的代码:
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()
This code is working.此代码正在运行。 So idk why this code is working and the first one is not.
所以我知道为什么这段代码有效而第一个无效。 NEED HELP !
需要帮忙 ! THX !
谢谢 !
The MySQL connector needs at least a list of 2 dimensions as parameter MySQL 连接器至少需要 2 个维度的列表作为参数
So change your code to因此,将您的代码更改为
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.