mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 02:54:29 +08:00
More precise get_autocommit based on server_status.
This commit is contained in:
@ -240,21 +240,10 @@ class Connection(_mysql.connection):
|
||||
|
||||
def autocommit(self, on):
|
||||
on = bool(on)
|
||||
_mysql.connection.autocommit(self, on)
|
||||
if self.get_autocommit() != 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()
|
||||
|
||||
def cursor(self, cursorclass=None):
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user