Skip to content Skip to sidebar Skip to footer

1064: SQL Syntax Error Executing PyMySQL Query

I am using PyMySQL to execute SQL query commands from python. My pystyle is pyformat which was found using: >>> pymysql.paramstyle pyformat My db and cursor details are a

Solution 1:

You can't pass a table name as a parameter to cursor.execute(). Whenever a parameter is a string it quotes it when it substitutes into the query. Use a normal string formatting method, e.g.

cursor.execute("SELECT * FROM %(tablename)s" % {"tablename": "activity"})

Post a Comment for "1064: SQL Syntax Error Executing PyMySQL Query"