summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/mysql.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-04-02 22:03:06 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-04-02 22:03:06 +0000
commitc416dad6c652262bafbb137e6412054481db8e2f (patch)
tree08d1b606fbe657011dd014ab4cd7d68165f7f063 /lib/sqlalchemy/databases/mysql.py
parentcdceb3c3714af707bfe3ede10af6536eaf529ca8 (diff)
downloadsqlalchemy-c416dad6c652262bafbb137e6412054481db8e2f.tar.gz
- merged the patch from #516 + fixes
- improves the framework for auto-invalidation of connections that have lost their underlying database - the error catching/invalidate step is totally moved to the connection pool. - added better condition checking for do_rollback() and do_commit() including SQLError excepetion wrapping
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r--lib/sqlalchemy/databases/mysql.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 65ccb6af1..7ea98e92f 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -328,21 +328,12 @@ class MySQLDialect(ansisql.ANSIDialect):
return MySQLIdentifierPreparer(self)
def do_executemany(self, cursor, statement, parameters, context=None, **kwargs):
- try:
- rowcount = cursor.executemany(statement, parameters)
- if context is not None:
- context._rowcount = rowcount
- except self.dbapi.OperationalError, o:
- if o.args[0] == 2006 or o.args[0] == 2014:
- cursor.invalidate()
- raise o
+ rowcount = cursor.executemany(statement, parameters)
+ if context is not None:
+ context._rowcount = rowcount
+
def do_execute(self, cursor, statement, parameters, **kwargs):
- try:
- cursor.execute(statement, parameters)
- except self.dbapi.OperationalError, o:
- if o.args[0] == 2006 or o.args[0] == 2014:
- cursor.invalidate()
- raise o
+ cursor.execute(statement, parameters)
def do_rollback(self, connection):
# MySQL without InnoDB doesnt support rollback()
@@ -351,6 +342,12 @@ class MySQLDialect(ansisql.ANSIDialect):
except:
pass
+ def get_disconnect_checker(self):
+ def disconnect_checker(e):
+ return isinstance(e, self.dbapi.OperationalError) and e.args[0] in (2006, 2014)
+ return disconnect_checker
+
+
def get_default_schema_name(self):
if not hasattr(self, '_default_schema_name'):
self._default_schema_name = text("select database()", self).scalar()