Not all parameters were used in the SQL statement (Python, MySQL)

后端 未结 3 1524
一个人的身影
一个人的身影 2020-11-29 06:03

I get an error on the following Python code:

import mysql.connector
cnx = mysql.connector.connect(user=\'root\', password=\'\',
                          hos         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 07:06

    use single quotations

    sql = 'insert into Student (id, fname, lname, school) values(%s, %s, %s , %s)'
    values = (4, "Gaddafi", "Adamu", "Informatic")
    
    a.execute(sql, values)
    
    mydb.commit()
    print(a.rowcount, "record inserted.")
    

提交回复
热议问题