summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/db/multi-db.txt3
-rw-r--r--docs/topics/db/sql.txt4
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