Python SQLite recordset with field names
I have googled and searched here, but can't seem to find an answer.
It appears that SQLite under Python only returns the values of a query but
not the column names, i.e. a dictionary:
def dbRows(sql):
con = dbapi.connect('/usr/share/mydb.sqlite')
cur = con.cursor()
cur.execute(sql)
return cur.fetchall()
> [(20, 1380506536631, '19:5d:ee3da0', 3, 'xxxx', 26.625, 30.0, 'true',
1379301655061, 0, 60, '10-0008017f31d3', 4, 0)]
How can I return the data as a dictionary type record set i.e ?
[(xx:20, xxx:1380506536631, xxxx:'19:5d:ee3da0', yy:3, yyy:'xxxx',
yyyy:26.625, zz:30.0, zzz:'true', zzzz:1379301655061, aa:0, aaa:60,
aaaa:'10-0008017f31d3', bb:4, bbb:0)]
No comments:
Post a Comment