raise ProgrammingError( mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement

ryhaxcpt  于 2022-12-22  发布在  Mysql
关注(0)|答案(1)|浏览(170)

i am trying to populate data in mysql from python using csv. till tuple my program is working fine. am able to see data but while uploading in sql. its giving error "Not all parameters used in sql statement"

with open("USERS.csv", "r") as f:
    val = []
    data = csv.reader(f)
    for row in data:
        val.append(tuple(row))
        print(tuple(row))
        cursor = mydb.cursor()
        sql=("insert into users (user_id, user_name, user_email,user_password,user_address,is_vendor)"
            " values(%s, %s , %s , %s , %s ,%d)")  
        cursor.execute(sql,tuple(row))

i al ready described above

dldeef67

dldeef671#

Looks like you are passing also the header data to the query, try to loop from the first row:

for i in range(1, len(data)):
    row = data[i]
    val.append(tuple(row))
    print(tuple(row))
    cursor = mydb.cursor()
    sql=("insert into users (user_id, user_name, user_email,user_password,user_address,is_vendor)"
        " values(%s, %s , %s , %s , %s ,%d)")  
    cursor.execute(sql, tuple(row))

相关问题