Maybe this is too late in the evening, but this is driving me nuts. I have an SQL statement with one placeholder:
sql = ("SELECT * FROM source AS s INNER JOIN bar AS B ON B.id = bar WHERE s.name = %s")
cursor = conn.cursor()
cursor.execute(sql, (source))
I always get an SQL error: mysql.connector.errors.ProgrammingError: 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' at line 1
However, when I modify the where clause to take the same variable twice, it works as intended.
sql = ("SELECT * FROM source AS s INNER JOIN bar AS B ON B.id = bar WHERE s.name = %s OR s.name = %s")
cursor = conn.cursor()
cursor.execute(sql, (source, source))
Anyone with an idea of what's going on?
sql = ("SELECT * FROM source AS s INNER JOIN bar AS B ON B.id = bar WHERE s.name = %s")
cursor = conn.cursor()
cursor.execute(sql, (source))
I always get an SQL error: mysql.connector.errors.ProgrammingError: 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' at line 1
However, when I modify the where clause to take the same variable twice, it works as intended.
sql = ("SELECT * FROM source AS s INNER JOIN bar AS B ON B.id = bar WHERE s.name = %s OR s.name = %s")
cursor = conn.cursor()
cursor.execute(sql, (source, source))
Anyone with an idea of what's going on?