Search code examples
pythonpymysql

Python: pymysql parameter query does not work


I am having hard time to using query, it just doing nothing without displaying error message.

I have list and put it into variable, which name is a b c .. so on, and using pymysql wanted to put in db

cursor.execute("INSERT INTO db (a, b, c, d, e) VALUES ({}, {}, {}, {}, {})", (a,b,c,d,e))

It supposed to insert in table but nothing happened


Solution

  • Just as all the examples show, the string for bound parameters is "%s".

    cursor.execute("INSERT INTO db (a, b, c, d, e) VALUES (%s, %s, %s, %s, %s)", (a, b, c, d, e))