diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-02-03 19:07:00 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-06 15:35:23 +0100 |
| commit | 3259983f569151232d8e3b0c3d0de3a858c2b265 (patch) | |
| tree | 4f1f19368fbb9d73ea5245d8fabe5e3097f51926 /django/db/backends/sqlite3 | |
| parent | f48f671223a20b161ca819cf7d6298e43b8ba5fe (diff) | |
Fixed #31233 -- Closed database connections and cursors after use.
Diffstat (limited to 'django/db/backends/sqlite3')
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 642d3d6c5a..7b3f90a2fd 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -296,7 +296,8 @@ class DatabaseWrapper(BaseDatabaseWrapper): return not bool(enabled) def enable_constraint_checking(self): - self.cursor().execute('PRAGMA foreign_keys = ON') + with self.cursor() as cursor: + cursor.execute('PRAGMA foreign_keys = ON') def check_constraints(self, table_names=None): """ @@ -309,7 +310,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): if self.features.supports_pragma_foreign_key_check: with self.cursor() as cursor: if table_names is None: - violations = self.cursor().execute('PRAGMA foreign_key_check').fetchall() + violations = cursor.execute('PRAGMA foreign_key_check').fetchall() else: violations = chain.from_iterable( cursor.execute('PRAGMA foreign_key_check(%s)' % table_name).fetchall() |
