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.
This error may be related to Keyboard Logger 1.1 from PanteraSoft.com, which is known to interfere with the network communication between MySQL Connector/ODBC and MySQL. When using some applications to access a MySQL server using Connector/ODBC and outer joins, an error is reported regarding the Outer Join Escape Sequence.
This error can be raised by a number of different issues, including server problems, network problems, and firewall and port blocking problems. For more information, see Can't connect to [local] MySQL server . The following error is reported when using transactions: Transactions are not enabled
Let’s get started! The MySQL 1064 error is a syntax error. This means the reason there’s a problem is because MySQL doesn’t understand what you’re asking it to do.
This error indicates that you are trying to use transactions with a MySQL table that does not support transactions. Transactions are supported within MySQL when using the InnoDB database engine, which is the default storage engine in MySQL 5.5 and higher. In versions of MySQL before MySQL 5.1, you may also use the BDB engine.
You are missing the comma to make userAuthInfo
a tuple. Change it to :
userAuthInfo = (givenUsername,)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With