Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

Python/Connect and Placeholders (no replies)

$
0
0
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?

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>