I am trying to convert an excel sheet into an sqlite3 db using win32com module in python. My excel sheet has 6 columns and so my a part of my python code is:
for row in exceldata:
c.execute('INSERT INTO exceltable1 VALUES(?,?,?,?,?,?)',row)
conn.commit()
But python gives me the following error:
c.execute('INSERT INTO exceltable VALUES(?,?,?,?,?,?)',row)
ProgrammingError: Incorrect number of bindings supplied. The current statement uses 6, and there are 5 supplied.
If I try to remove one question mark and run it again, the error now becomes:
c.execute('INSERT INTO exceltable1 VALUES(?,?,?,?,?)',row)
OperationalError: table exceltable1 has 6 columns but 5 values were supplied
Could anyone please explain to me whats happening here and if there is any solution…
Thx.
First of all, make sure what the value of
rowis, and how many items it has:Then try and use the complete insert sql statement:
and see what happens. This should solve your problem, or at least let you understand what is happening.