那個我算了一下~看起來是insert插入欄位有異常吧~
你要不要先把SQL印出來~再貼去Mysql執行看看錯誤在哪裡~
換這種方式試看看
connection = mysql.connector.connect(host='localhost',
database='python_db',
user='root')
cursor = connection.cursor(prepared=True)
# Parameterized query
sql_insert_query = """ INSERT INTO Employee
(id, Name, Joining_date, salary) VALUES (%s,%s,%s,%s)"""
# tuple to insert at placeholder
tuple1 = (1, "Json", "2019-03-23", 9000)
tuple2 = (2, "Emma", "2019-05-19", 9500)
cursor.execute(sql_insert_query, tuple1)
cursor.execute(sql_insert_query, tuple2)
connection.commit()