diff options
Diffstat (limited to 'django/db/backends/sqlite3/base.py')
| -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() |
