Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Incorrect number of bindings supplied. The current statement uses 11, and there are 10 supplied

I´m Learning Coding and the Error Message from the Debugging confuse me a bit,
when i try to create a SQLlite Database with 11 statements, i have two different Errors.

here my Code:

import sqlite3

connection = sqlite3.connect("wtime1.db")
cursor = connection.cursor()



date = ("31.10.2022")
p_unit = ("MMO")
equip = ("D014-K-00001")
report_prio = ("1")
order_prio = ("2")
job = ("Oel wechsel")
w_time = ("120")
fte = ("2")
reason = ("Kein Oel vorhanden")
cause = ("MAR 2")
solved = ("Erledigt")

mar2_list = ([date, p_unit, equip, report_prio, order_prio, job, w_time, fte, reason, cause, solved])


cursor.execute("create table if not exists mar21 (DATE integer, P_UNIT text, EQUIP text, REPORT_PRIO text, ORDER_PRIO text, JOB text, W_TIME integer, FTE integer, REASON text, CAUSE text, SOLVED text)")
cursor.executemany("insert into mar21 values (?,?,?,?,?,?,?,?,?,?,?)", mar2_list)

the first Error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Incorrect number of bindings supplied. The current statement uses 11, and there are 10 supplied.
  File "C:\Users\andre\PycharmProjects\Wartezeiten\db_test.py", line 26, in <module>
    cursor.executemany("insert into mar21 values (?,?,?,?,?,?,?,?,?,?,?)", mar2_list)

Okay i found in my search i need one more comma at the end of the Values
when i set the comma like this

cursor.executemany("insert into mar21 values (?,?,?,?,?,?,?,?,?,?,?,)", mar2_list)

i have a syntax error

near ")": syntax error
  File "C:\Users\andre\PycharmProjects\Wartezeiten\db_test.py", line 26, in <module>
    cursor.executemany("insert into mar21 values (?,?,?,?,?,?,?,?,?,?,?,)", mar2_list)

i think i´m running a wrong way with the "insert values" line!

>Solution :

since you have one record use execute instead of executemany

cursor.execute("insert into mar21 values (?,?,?,?,?,?,?,?,?,?,?)", mar2_list)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading