简体   繁体   English

错误 1064 (42000):您的 SQL 语法中存在错误,接近使用 %s

[英]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.

相关问题 mysql.connector.errors.ProgrammingError: 1064 (42000): 你的 SQL 语法有错误; 在第 1 行的“)”附近使用正确的语法 - mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; for the right syntax to use near ')' at line 1 错误:'1064 (42000):您的 SQL 语法有错误 - Error: '1064 (42000): You have an error in your SQL syntax 1064SQL语法有错误。 以便在第1行的'%s'附近使用正确的语法”) - 1064, “You have an error in your SQL syntax; for the right syntax to use near '%s' at line 1”) 1064 (42000):您的 SQL 语法有错误; - 1064 (42000): You have an error in your SQL syntax; Python MySQL, 1064 (42000), “您的 SQL 语法有错误;...” - Python MySQL, 1064 (42000), "You have an error in your SQL syntax;..." 1064(42000):您的 SQL 语法有错误; 检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法使用 - 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 插入出错 1064 (42000): 您的 SQL 语法有错误; - insertion went wrong 1064 (42000): You have an error in your SQL syntax; 更新表记录失败:1064 (42000):您的 SQL 语法有错误; Python - Failed to update table record: 1064 (42000): You have an error in your SQL syntax; Python 1064, "你的 SQL 语法有错误 - 1064, "You have an error in your SQL syntax _mysql_exceptions.ProgrammingError:(1064,“您的SQ L语法有错误;在第1行的')'附近使用了正确的语法”) - _mysql_exceptions.ProgrammingError: (1064, “You have an error in your SQ L syntax; right syntax to use near ')' at line 1”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM