summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-04-03 16:06:06 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-04-03 16:06:06 +0000
commit030ef1f0ef37ccaebde06e58f22cd0de5a74c5d0 (patch)
tree2f596ed664bb60c7154c61add363d5532bb0782f /lib/sqlalchemy/engine/base.py
parentc416dad6c652262bafbb137e6412054481db8e2f (diff)
downloadsqlalchemy-030ef1f0ef37ccaebde06e58f22cd0de5a74c5d0.tar.gz
for #516, moved the "disconnect check" step out of pool and back into base.py. dialects have
is_disconnect() method now. simpler design which also puts control of the ultimate "execute" call back into the hands of the dialects.
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 80d93e61c..f5b4b377e 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -246,10 +246,9 @@ class Dialect(sql.AbstractDialect):
return clauseelement.compile(dialect=self, parameters=parameters)
- def get_disconnect_checker(self):
- """Return a callable that determines if an SQLError is caused by a database disconnection."""
-
- return lambda x: False
+ def is_disconnect(self, e):
+ """Return True if the given DBAPI error indicates an invalid connection"""
+ raise NotImplementedError()
class ExecutionContext(object):
@@ -576,6 +575,8 @@ class Connection(Connectable):
try:
context.dialect.do_execute(context.cursor, context.statement, context.parameters, context=context)
except Exception, e:
+ if self.dialect.is_disconnect(e):
+ self.__connection.invalidate(e=e)
self._autorollback()
if self.__close_with_result:
self.close()
@@ -585,6 +586,8 @@ class Connection(Connectable):
try:
context.dialect.do_executemany(context.cursor, context.statement, context.parameters, context=context)
except Exception, e:
+ if self.dialect.is_disconnect(e):
+ self.__connection.invalidate(e=e)
self._autorollback()
if self.__close_with_result:
self.close()