Reputation: 943
I have a list of integers with >2000 items and so I can't split each value into a column of its own due to the 2000 column limit for SQL:
a = [1, 0, 0, 1, 0,....]
and another str value
version = 'dog'
How should I be writing the code so that I can input the list, as is, into a single cell, possibly a BLOB type cell?
import sqlite3 as sql
con = sql.connect('test.db')
cur = con.cursor()
cur.execute("CREATE TABLE tablename(Version TEXT, A BLOB)")
cur.execute("CREATE INDEX Idx_Version ON tablename(Version)")
tuples = tuple([tuple(version, a)])
cur.execute('INSERT INTO tablename VALUES (?, ?)', tuples)
I'm fairly new to SQL and would appreciate any help I can get
Upvotes: 0
Views: 1431
Reputation: 21
>>list1 = [1, 2, 3]
>>string = ''.join([str(e) for e in list1])
>>string
'123'
Upvotes: 2