0
m = input('Num1:')
m = int(m)
x1 = (m-1)
#
m = input('Num2:')
m = int(m)
x2 = (m-1)
#
z = [0,0,0,0,0,0,0,0,0]
z[(x1)] = 1
z[(x2)] = 1
##########################################
import mysql.connector
list = z
print(list)
mydb = mysql.connector.connect(host="localhost", user="root", passwd="onsdag", db="eno")
conn = mydb.cursor()
params = ['?' for item in list]
sql = 'INSERT INTO bola (n01, n02, n03, n04, n05, n06, n07, n08, n09) VALUES (%s);' % ','.join(params)
conn.execute(sql, list)
mydb.commit()
print(conn.rowcount, 'record inserted')
print(conn.rowcount, 'record inserted')
Num1:5
Num2:8
[0, 0, 0, 0, 1, 0, 0, 1, 0]
Traceback (most recent call last):
 File "inputxx.py", line 26, in <module>
 conn.execute(sql, list)
 File "/home/amb/.local/lib/python3.6/site-packages/mysql/connector/cursor.py", line 543, in execute
 "Not all parameters were used in the SQL statement")
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
Devesh Kumar Singh
20.5k5 gold badges25 silver badges43 bronze badges
asked Jan 1, 2020 at 12:21
0

1 Answer 1

1

The problem is in your MySQL Insert script. You can update this as shown below.

conn.execute("INSERT INTO bola(n01, n02, n03, n04, n05, n06, n07, n08, n09) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)",tuple(data))

Your values count should always match the number of columns.

Here the data is a list object.

answered Jan 1, 2020 at 13:50
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.