G
Gilles Ganault
Hello
I'm using the APSW wrapper to SQLite, and I'm stuck at how to pass
data from a dictionary to the database which expects an integer:
#array filled by reading a two-column text file as input
for (isbn,carton) in data.items():
#TypeError: int argument required
sql = "INSERT INTO books (isbn,carton) VALUES ('%s',%u)" %
(isbn,carton)
#Incorrect number of bindings supplied. The current statement uses
0 and there are 2 supplied. Current offset is 0
sql = "INSERT INTO books (isbn,carton) VALUES ('%s',%u)" %
(isbn,int(carton))
cursor.execute(sql,(isbn,carton))
==========
What is the right way to turn items from a dictionary into an integer
so as to match the column definition in the database?
Thank you.
I'm using the APSW wrapper to SQLite, and I'm stuck at how to pass
data from a dictionary to the database which expects an integer:
#array filled by reading a two-column text file as input
for (isbn,carton) in data.items():
#TypeError: int argument required
sql = "INSERT INTO books (isbn,carton) VALUES ('%s',%u)" %
(isbn,carton)
#Incorrect number of bindings supplied. The current statement uses
0 and there are 2 supplied. Current offset is 0
sql = "INSERT INTO books (isbn,carton) VALUES ('%s',%u)" %
(isbn,int(carton))
cursor.execute(sql,(isbn,carton))
==========
What is the right way to turn items from a dictionary into an integer
so as to match the column definition in the database?
Thank you.