Python/MySQL "Insert into" with variables -


i have problem inserting new rows mysql table. name of table change, must variable , have trouble. how can change name of table "second" variable? idea?

add_word = ("insert second "                "(name, surname) "                "values (%s, %s)")     data_word = (name1, surname1)     cursor.execute(add_word, data_word) 

you this:

add_word = "insert %s (name, surname) values ('%s', '%s')"%('table_name','name','surname1') 

and don't need data_word:

cursor.execute(add_word, params=none, multi=false) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -