소스 검색

Fixed #25455 -- Optimized dictfetchall() example.

Thanks aklim007 for the suggestion.
Tim Graham 9 년 전
부모
커밋
361f60479d
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      docs/topics/db/sql.txt

+ 2 - 2
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()
         ]