diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-11 21:08:49 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-11 21:08:49 +0100 |
| commit | f2f98abb955c83eca3ceea62d1711c80ae028d33 (patch) | |
| tree | 2613eacb049f985d001d73ca2e60a528f3ec84c5 /django/db | |
| parent | b746f8a9e3fb22fe5ff58bd2bd8b20fa80cd4800 (diff) | |
Avoided closing the database connection within a transaction.
Refs #9437.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/__init__.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 09a33eebae..c797a50733 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -472,11 +472,13 @@ class BaseDatabaseWrapper(object): Context manager that ensures that a connection is established, and if it opened one, closes it to avoid leaving a dangling connection. This is useful for operations outside of the request-response cycle. + + Provides a cursor: with self.temporary_connection() as cursor: ... """ must_close = self.connection is None cursor = self.cursor() try: - yield + yield cursor finally: cursor.close() if must_close: |
