>
> I got it to work ..
>
def dictfetchall(cursor):
"Returns all rows from a cursor as a dict"
fieldnames = [name[0] for name in cursor.description]
result = []
for row in cursor.fetchall():
rowset = []
for field in zip(fieldnames, row):
L=list(field)
Hello,
I am trying to use cursor to execute a sql and convert the results to a
dictionary
def dictfetchall(cursor):
"Return all rows from a cursor as a dict"
columns = [col[0] for col in cursor.description]
return [
dict(zip(columns, row))
for row in cursor.fetchall()
2 matches
Mail list logo