diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2017-11-28 05:12:28 -0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-28 11:28:09 -0500 |
| commit | 7a6fbf36b1fdb8978ea0842075ccce83bcd63789 (patch) | |
| tree | a48e72be7e31066d92de43a85458b0bfb7e2cfcd /docs | |
| parent | 3308085838f520db49f606b72345a301c1cf2a3e (diff) | |
Fixed #28853 -- Updated connection.cursor() uses to use a context manager.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/db/multi-db.txt | 3 | ||||
| -rw-r--r-- | docs/topics/db/sql.txt | 4 |
2 files changed, 4 insertions, 3 deletions
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 |
