I'm referencing this page in order to make a SELECT query to my database. However, I'm getting this 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
Here's the section of code with the problem:
import mysql.connector
cnx = mysql.connector.connect(user='xxxx', password='yyyy',
host='zzzz.us-west-2.rds.amazonaws.com',
database='iiii')
cursor = cnx.cursor()
# ...
givenUsername = 'testUser123'
checkUserAuthQuery = ("SELECT password FROM UserAuth WHERE username = %s")
userAuthInfo = (givenUsername)
cursor.execute(checkUserAuthQuery, userAuthInfo)
# ...
Notes:
- When doing an INSERT query with %s
it works.
- Also, replacing %s
with 'testuser123'
works.