From e4e6bf0712fdd774e73bea7aadf799656544b513 Mon Sep 17 00:00:00 2001 From: Jason Pellerin Date: Tue, 28 Nov 2006 15:48:39 +0000 Subject: [PATCH] [multi-db] For all backends: commit only when a connection exists. git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@4127 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/ado_mssql/base.py | 3 ++- django/db/backends/mysql/base.py | 3 ++- django/db/backends/oracle/base.py | 3 ++- django/db/backends/postgresql/base.py | 3 ++- django/db/backends/postgresql_psycopg2/base.py | 3 ++- django/db/backends/sqlite3/base.py | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 25832e25df..8d813c6704 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -70,7 +70,8 @@ class DatabaseWrapper(object): return cursor def _commit(self): - return self.connection.commit() + if self.connection: + return self.connection.commit() def _rollback(self): if self.connection: diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index b760f47786..6040b9c5f3 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -91,7 +91,8 @@ class DatabaseWrapper(object): return cursor def _commit(self): - self.connection.commit() + if self.connection: + self.connection.commit() def _rollback(self): if self.connection: diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index a9a0662c15..754fcef776 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -36,7 +36,8 @@ class DatabaseWrapper(object): return FormatStylePlaceholderCursor(self.connection) def _commit(self): - self.connection.commit() + if self.connection: + self.connection.commit() def _rollback(self): if self.connection: diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 774b52a1d6..cc6686ed81 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -43,7 +43,8 @@ class DatabaseWrapper(object): return cursor def _commit(self): - return self.connection.commit() + if self.connection: + return self.connection.commit() def _rollback(self): if self.connection: diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 65f3e698ae..d62376596f 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -44,7 +44,8 @@ class DatabaseWrapper(object): return cursor def _commit(self): - return self.connection.commit() + if self.connection: + return self.connection.commit() def _rollback(self): if self.connection: diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index e6aff2d847..2d42700e63 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -56,7 +56,8 @@ class DatabaseWrapper(local): return cursor def _commit(self): - self.connection.commit() + if self.connection: + self.connection.commit() def _rollback(self): if self.connection: