From bb90e8fa2b1222c6408f4cfacac2c66955f75622 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 24 Sep 2015 13:17:39 -0400 Subject: [PATCH] [1.8.x] Fixed #25455 -- Optimized dictfetchall() example. Thanks aklim007 for the suggestion. Backport of 361f60479d1890e8144fc254d7389a67b35725e9 from master --- docs/topics/db/sql.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/topics/db/sql.txt b/docs/topics/db/sql.txt index dc40d1f3e6..debebb0fa2 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() ]