python - Pass SQL column name as attribute of cursor.execute() -


i want pass column name attribute of function cursor.execute()

conn = sqlite3.connect(db) cursor = conn.cursor() cursor.execute("insert table (?) values (?)", (column, value)) 

is possible?

in current form receive error syntaxerror: invalid syntax

this work, assuming column not user defined input.

cursor.execute(     "insert table ({column}) values (?)".format(column=column),     (value,) ) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -