Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #298 from zhanghaofei/begin_transaction_reconnect_…
Browse files Browse the repository at this point in the history
…by_lost

If mysql begin a transaction and lost connection, reconnect
  • Loading branch information
josephmancuso authored Jul 26, 2019
2 parents 8aaeafe + 5dd2702 commit e5d48d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion orator/connections/mysql_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ def get_schema_manager(self):
return MySQLSchemaManager(self)

def begin_transaction(self):
self._connection.autocommit(False)
self._reconnect_if_missing_connection()

try:
self._connection.autocommit(False)
except Exception as e:
if self._caused_by_lost_connection(e):
self.reconnect()
self._connection.autocommit(False)
else:
raise

super(MySQLConnection, self).begin_transaction()

Expand Down

0 comments on commit e5d48d6

Please sign in to comment.