SQLite Forum

sqlite bindings error
# (API Call Happens and Works)#
r = requests.get(url, params=data) #<-- This is CSV

btc_price_rows = r.text <-- I can print this and see the correct data 

# connect to db, create tables and insert #
c.execute("CREATE TABLE IF NOT EXISTS btc_price_table (btc_price_timestamp TEXT, btc_price_value REAL)")

values = (btc_price_rows,)

c.executemany("INSERT OR REPLACE INTO btc_price_table VALUES (?, ?)", (values,)) <-- I think this is the problem but not sure why 

# I get this error # 
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 19931624 supplied.

My best guess here is that it has something to do with r and btc_price_rows are being presented to sqlite, I guess it's confused about columns vs data, it thinks every row of data is a unique column value? Hence the expecting 2 got 19931624 error? 

if I print the data out it looks like this, just two columns, time and value. 


I read that ISO8601 RFC3339 is the time format which I believe sqlite wants it defined as datatype TEXT. 

Appreciate any help on figuring this out.