I am trying to do this
cursor.execute("""INSERT INTO my_stats VALUES (%s,%s)""" % (time.strftime('%Y-%m-%d'), info["countries"]))
where info[“countries’] is a json string like this
{“US” : 8997, “BG” : 78 ….}
I keep getting syntax error exception from MySQL
I am using Python-MysqlDB
You have an extra double-quote at the start of the query string.
Also, you should be passing your parameters as a second argument to
executeto avoid SQL injection attacks; and to ensure that the values are properly quoted, e.g.:If you post the error you’re getting we’ll be able to help more.