diff options
| author | Tim Graham <timograham@gmail.com> | 2015-09-24 13:17:39 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-09-24 13:19:17 -0400 |
| commit | ca2c5508be47af88bda040abd9bc95e8f3087c12 (patch) | |
| tree | 7fb94f685ad56dd2ed7acab5cc57eb8c99e5bc76 | |
| parent | a2cf430c80bc844f557b150b79cdf7ef5496ed0b (diff) | |
[1.9.x] Fixed #25455 -- Optimized dictfetchall() example.
Thanks aklim007 for the suggestion.
Backport of 361f60479d1890e8144fc254d7389a67b35725e9 from master
| -rw-r--r-- | docs/topics/db/sql.txt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/topics/db/sql.txt b/docs/topics/db/sql.txt index 999853c5ee..a7970928f1 100644 --- a/docs/topics/db/sql.txt +++ b/docs/topics/db/sql.txt @@ -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() ] |
