summaryrefslogtreecommitdiff
path: root/MySQLdb
diff options
context:
space:
mode:
authorAndy Dustman <farcepest@gmail.com>2013-11-21 11:57:32 -0800
committerAndy Dustman <farcepest@gmail.com>2013-11-21 11:57:32 -0800
commit95ae115c7d6b49dadec06af943ab03bef04f52fa (patch)
tree4db1628ba792ae82b41f2c6cd25f618c2161be6d /MySQLdb
parent9b0b59f1bbe0029757b9b15d1c71586eaca1109c (diff)
parent2204283605e8c450223965eda8d8f357d5fe4c90 (diff)
downloadmysqldb1-95ae115c7d6b49dadec06af943ab03bef04f52fa.tar.gz
Merge pull request #32 from methane/autocommit
More precise get_autocommit based on server_status.
Diffstat (limited to 'MySQLdb')
-rw-r--r--MySQLdb/connections.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py
index 40a6150..908706a 100644
--- a/MySQLdb/connections.py
+++ b/MySQLdb/connections.py
@@ -232,7 +232,6 @@ class Connection(_mysql.connection):
self.encoders[types.StringType] = string_literal
self.encoders[types.UnicodeType] = unicode_literal
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
- self._autocommit = None
if self._transactional:
if autocommit is not None:
self.autocommit(autocommit)
@@ -240,20 +239,8 @@ class Connection(_mysql.connection):
def autocommit(self, on):
on = bool(on)
- _mysql.connection.autocommit(self, on)
- self._autocommit = on
-
- def get_autocommit(self):
- if self._autocommit is None:
- self._update_autocommit()
- return self._autocommit
-
- def _update_autocommit(self):
- cursor = cursors.Cursor(self)
- cursor.execute("SELECT @@AUTOCOMMIT")
- row = cursor.fetchone()
- self._autocommit = bool(row[0])
- cursor.close()
+ if self.get_autocommit() != on:
+ _mysql.connection.autocommit(self, on)
def cursor(self, cursorclass=None):
"""