Am having problems with MySql not recognizing this syntax.
I think the issue is in the the exceute statement. I was using their previous method https://dev.mysql.com/doc/connector-python/en/connector-python-example-cursor-transaction.html
def insertPS3(name,gamedb):
mycursor = gamedb.cursor()
mycursor.execute("""INSERT INTO ps3 (name) VALUES (%s,)""" % (name,))
gamedb.commit()
Edit
'%s' is the fix
Instead of formatting the SQL statement using python string formatting you should let the cursor handle it for you. Passing a tuple of params as the second argument to execute
(the same length as the number of %s
s in the statement) will allow the cursor to perform the correct string formatting
mycursor.execute("INSERT INTO ps3 (name) VALUES (%s)", (name,))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.