vendredi 3 avril 2015

Error binding parameter 0 - probably unsupported type

I am creating an SQL db and trying to iterate over an excel file and put all the data in to the SQL table as follows but I keep getting an annoying error. I have looked at the data types and still can't get my head around it please let me know if anyone spots what the problem is my code is:



import sqlite3
from openpyxl import load_workbook

#wb = load_workbook(r"LeaguePlayers.xlsx")

#read workbook to get data
wb = load_workbook(filename = r"LeaguePlayers.xlsx", use_iterators = True)
ws = wb.get_sheet_by_name(name = 'Sheet1')
#ws = wb.worksheets



conn = sqlite3.connect("players.db") # or use :memory: to put it in RAM

cursor = conn.cursor()

# create a table
cursor.execute("""CREATE TABLE players
(player TEXT,
team TEXT,
points INTEGER,
cost REAL,
position TEXT)
""")


#Iterate through worksheet and print cell contents
for row in ws.iter_rows():
for cell in row:
cursor.execute("INSERT INTO players VALUES (?,?,?,?,?)", row)

conn.commit()

#----------------------------------------
# display SQL data
#----------------------------------------
c.execute('SELECT * FROM players')
for row in c:
print (row)


The error i get says:


cursor.execute("INSERT INTO players VALUES (?,?,?,?,?)", row) sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.


Aucun commentaire:

Enregistrer un commentaire