From ca2c5508be47af88bda040abd9bc95e8f3087c12 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 24 Sep 2015 13:17:39 -0400 Subject: [PATCH] [1.9.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 999853c5ee3..a7970928f15 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() ]