summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql_psycopg2/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index 23da101d01..d44bb5cdd9 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -169,14 +169,15 @@ class DatabaseWrapper(BaseDatabaseWrapper):
self.connection.set_isolation_level(isolation_level)
def _set_autocommit(self, autocommit):
- if self.psycopg2_version >= (2, 4, 2):
- self.connection.autocommit = autocommit
- else:
- if autocommit:
- level = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT
+ with self.wrap_database_errors:
+ if self.psycopg2_version >= (2, 4, 2):
+ self.connection.autocommit = autocommit
else:
- level = self.isolation_level
- self.connection.set_isolation_level(level)
+ if autocommit:
+ level = psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT
+ else:
+ level = self.isolation_level
+ self.connection.set_isolation_level(level)
def check_constraints(self, table_names=None):
"""