Kaydet (Commit) ccf7adb0 authored tarafından Chris Jerdonek's avatar Chris Jerdonek Kaydeden (comit) Claude Paroz

Fixed #27172 -- Closed database cursor explicitly in two doc examples

üst 6a2af014
......@@ -67,7 +67,7 @@ returns a list of all ``OpinionPoll`` objects, each with an extra
class PollManager(models.Manager):
def with_counts(self):
from django.db import connection
cursor = connection.cursor()
with connection.cursor() as cursor:
cursor.execute("""
SELECT p.id, p.question, p.poll_date, COUNT(*)
FROM polls_opinionpoll p, polls_response r
......
......@@ -250,10 +250,8 @@ For example::
from django.db import connection
def my_custom_sql(self):
cursor = connection.cursor()
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment