标签: python mysql python-3.x mysql-connector mysql-connector-python
使用MySql连接器和Python时,如何将Python变量值插入MySql表?
示例:
data = 5 cursor.execute("""INSERT INTO table1 VALUES ( data )""")
我想将'data'的值插入表名'table1'
答案 0 :(得分:0)
data = 5 cursor.execute("INSERT INTO table1 VALUES ( ?)", (data,))