In an effort to make Django a bit more explicit with regards to closing
cursors when they are no longer needed, I have created ticket #21751 [1]
with a pull request[2].

Most of the changes are straight forward and change the usage of a cursor
so that it uses a context manager or closes the cursor in 'finally'.

Example:

# old pattern
connection.cursor().execute(...)

# changes to
with connection.cursor() as cursor:
   cursor.execute(...)

The biggest change is with SQLCompiler.execute_sql. I added new constants
to make the usage of execute_sql more explicit (and self documenting) for
the cases when the caller wants no result and when the caller wants to
fetch the results from the cusor directly.

[1] https://code.djangoproject.com/ticket/21751
[2] https://github.com/django/django/pull/2154

Regards,
Michael Manfre

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAGdCwBv1nO%3D-H9j-nHUXTsdC-V0OF50fOgbYBXhuWs%2BGeB4M0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to