summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-09-24 13:17:39 -0400
committerTim Graham <timograham@gmail.com>2015-09-24 13:17:39 -0400
commit361f60479d1890e8144fc254d7389a67b35725e9 (patch)
tree7c220de2e097a420e237cf6c797e4283ef46ba2f
parentce531f7ad783facc5799cf43b59b5ce053aa5d9e (diff)
Fixed #25455 -- Optimized dictfetchall() example.
Thanks aklim007 for the suggestion.
-rw-r--r--docs/topics/db/sql.txt4
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()
]