From 5280f26d45f6d79013d2da3bd5e0fe4a88117b20 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 10 Apr 2012 19:38:22 -0400 Subject: - [feature] Added new connection event dbapi_error(). Is called for all DBAPI-level errors passing the original DBAPI exception before SQLAlchemy modifies the state of the cursor. --- lib/sqlalchemy/engine/base.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/sqlalchemy/engine/base.py') diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 1f28501f7..110ac4e8a 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1806,10 +1806,19 @@ class Connection(Connectable): (statement is not None and context is None) if should_wrap and context: + if self._has_events: + self.engine.dispatch.dbapi_error(self, + cursor, + statement, + parameters, + context, + e) context.handle_dbapi_exception(e) is_disconnect = isinstance(e, self.dialect.dbapi.Error) and \ self.dialect.is_disconnect(e, self.__connection, cursor) + + if is_disconnect: self.invalidate(e) self.engine.dispose() -- cgit v1.2.1