diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-08 03:27:09 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-08 03:27:09 +0000 |
commit | c6538b6b3400cbfa939d4e3e8d0f0530e0530e9d (patch) | |
tree | e9d9713d8b437a425ea0bed1ccc33c2b62cff0e5 /lib/sqlalchemy/databases/mysql.py | |
parent | 21d4e2a96eb8f505e8d2c942204917477c4323d3 (diff) | |
download | sqlalchemy-c6538b6b3400cbfa939d4e3e8d0f0530e0530e9d.tar.gz |
- MySQL detects errors 2006 (server has gone away) and 2014
(commands out of sync) and invalidates the connection on which it occured.
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 325347464..662d276e9 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -289,6 +289,22 @@ class MySQLDialect(ansisql.ANSIDialect): def preparer(self): return MySQLIdentifierPreparer(self) + def do_executemany(self, cursor, statement, parameters, **kwargs): + try: + cursor.executemany(statement, parameters) + except mysql.OperationalError, o: + if o.args[0] == 2006 or o.args[0] == 2014: + cursor.invalidate() + raise o + def do_execute(self, cursor, statement, parameters, **kwargs): + try: + cursor.execute(statement, parameters) + except mysql.OperationalError, o: + if o.args[0] == 2006 or o.args[0] == 2014: + cursor.invalidate() + raise o + + def do_rollback(self, connection): # some versions of MySQL just dont support rollback() at all.... try: |