#27172: Close cursor in custom SQL example --------------------------------------+-------------------- Reporter: cjerdonek | Owner: nobody Type: Cleanup/optimization | Status: new Component: Documentation | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+-------------------- It would be better if [https://docs.djangoproject.com/en/dev/topics/db/sql /#executing-custom-sql-directly here] in this example, the cursor were explicitly closed (e.g. by using `with connection.cursor() as cursor`): {{{#!python 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() return row }}} -- Ticket URL: <https://code.djangoproject.com/ticket/27172> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.9c1488f60c7e9b750e49fb4720e6991d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.