From 7a6fbf36b1fdb8978ea0842075ccce83bcd63789 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 28 Nov 2017 05:12:28 -0800 Subject: Fixed #28853 -- Updated connection.cursor() uses to use a context manager. --- docs/topics/db/multi-db.txt | 3 ++- docs/topics/db/sql.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt index 78f3fe23d9..394d25cfd9 100644 --- a/docs/topics/db/multi-db.txt +++ b/docs/topics/db/multi-db.txt @@ -664,7 +664,8 @@ object that allows you to retrieve a specific connection using its alias:: from django.db import connections - cursor = connections['my_db_alias'].cursor() + with connections['my_db_alias'].cursor() as cursor: + ... Limitations of multiple databases ================================= diff --git a/docs/topics/db/sql.txt b/docs/topics/db/sql.txt index dc2bcc50b6..96d79a999c 100644 --- a/docs/topics/db/sql.txt +++ b/docs/topics/db/sql.txt @@ -279,8 +279,8 @@ object that allows you to retrieve a specific connection using its alias:: from django.db import connections - cursor = connections['my_db_alias'].cursor() - # Your code here... + with connections['my_db_alias'].cursor() as cursor: + # Your code here... By default, the Python DB API will return results without their field names, which means you end up with a ``list`` of values, rather than a ``dict``. At a -- cgit v1.3