执行准备好的语句的参数数量不正确

时间:2018-11-03 20:32:13

标签: python mysql

import mysql.connector

cursor = ""
cnx = ""
cnx = mysql.connector.connect(host='127.0.0.1',
                              database='web_data',
                              user='root', 
                              password='admin',
                              use_pure=True
                              )
cursor = cnx.cursor(prepared=True) #this will return MySQLCursorPrepared object


sql = "INSERT INTO my_table (h1) VALUES (%s)"
my_heading= "hello"
insert_tuple = (my_heading)
result  = cursor.execute(sql, insert_tuple)
cnx.commit()
print ("variable inserted successfully into employee table using the prepared statement")

我想将数据插入数据库,但显示错误。 my_table只有两列。 1.标题(int) 2.h1(varchar)

请确定错误。

0 个答案:

没有答案