mirror of
https://github.com/django/django.git
synced 2025-04-24 17:24:37 +00:00
[1.8.x] Fixed #25455 -- Optimized dictfetchall() example.
Thanks aklim007 for the suggestion. Backport of 361f60479d1890e8144fc254d7389a67b35725e9 from master
This commit is contained in:
parent
66f50e97d6
commit
bb90e8fa2b
@ -282,9 +282,9 @@ using something like this::
|
||||
|
||||
def dictfetchall(cursor):
|
||||
"Return all rows from a cursor as a dict"
|
||||
desc = cursor.description
|
||||
columns = [col[0] for col in cursor.description]
|
||||
return [
|
||||
dict(zip([col[0] for col in desc], row))
|
||||
dict(zip(columns, row))
|
||||
for row in cursor.fetchall()
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user