mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #27172 -- Closed database cursor explicitly in two doc examples
This commit is contained in:
committed by
Claude Paroz
parent
6a2af01452
commit
ccf7adb064
@@ -250,12 +250,10 @@ For example::
|
||||
from django.db import connection
|
||||
|
||||
def my_custom_sql(self):
|
||||
cursor = connection.cursor()
|
||||
|
||||
cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz])
|
||||
|
||||
cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
|
||||
row = cursor.fetchone()
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz])
|
||||
cursor.execute("SELECT foo FROM bar WHERE baz = %s", [self.baz])
|
||||
row = cursor.fetchone()
|
||||
|
||||
return row
|
||||
|
||||
|
||||
Reference in New Issue
Block a user