It\'s annoying how Python\'s sqlite3 module always returns a list of tuples! When I am querying a single column, I would prefer to get a plain list.
e.g. when I exec
zlist = []
tupls = c.fetchall()
for tup in tupls:
t = str(tup).replace("('","").replace("',)","")
zlist.append(t)
Now you don't have to deal with tuples, pandas or any of the above that didn't work.
data=cursor.fetchall()
COLUMN = 0
column=[elt[COLUMN] for elt in data]
(My previous suggestion, column=zip(*data)[COLUMN]
, raises an IndexError
if data
is an empty tuple. In contrast, the list comprehension above just creates an empty list. Depending on your situation, raising an IndexError
may be preferable, but I'll leave that to you to decide.)