﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28853	Use database cursor as a context manager internally	Jon Dufresne	nobody	"While reading the code Django code, I noticed some uses of `connection.cursor()` weren't being used as a context manager. For example:

https://github.com/django/django/blob/4f5526e346861c0b2ffa2ea7229747c883e14432/django/test/testcases.py#L855-L857

{{{
def _reset_sequences(self, db_name):
    ...
    cursor = conn.cursor()
    for sql in sql_list:
        cursor.execute(sql)
}}}

This pattern exists multiple time throughout Django. Using a context manager helps ensure resources are closed deterministically and that errors aren't hidden."	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
