summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/events.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/events.py')
-rw-r--r--lib/sqlalchemy/events.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/sqlalchemy/events.py b/lib/sqlalchemy/events.py
index 504dfe150..99af804f6 100644
--- a/lib/sqlalchemy/events.py
+++ b/lib/sqlalchemy/events.py
@@ -166,7 +166,7 @@ class DDLEvents(event.Events):
"""
- def column_reflect(self, table, column_info):
+ def column_reflect(self, inspector, table, column_info):
"""Called for each unit of 'column info' retrieved when
a :class:`.Table` is being reflected.
@@ -188,7 +188,7 @@ class DDLEvents(event.Events):
from sqlalchemy.schema import Table
from sqlalchemy import event
- def listen_for_reflect(table, column_info):
+ def listen_for_reflect(inspector, table, column_info):
"receive a column_reflect event"
# ...
@@ -200,7 +200,7 @@ class DDLEvents(event.Events):
...or with a specific :class:`.Table` instance using
the ``listeners`` argument::
- def listen_for_reflect(table, column_info):
+ def listen_for_reflect(inspector, table, column_info):
"receive a column_reflect event"
# ...
@@ -401,6 +401,36 @@ class ConnectionEvents(event.Events):
parameters, context, executemany):
"""Intercept low-level cursor execute() events."""
+ def dbapi_error(self, conn, cursor, statement, parameters,
+ context, exception):
+ """Intercept a raw DBAPI error.
+
+ This event is called with the DBAPI exception instance
+ received from the DBAPI itself, *before* SQLAlchemy wraps the
+ exception with it's own exception wrappers, and before any
+ other operations are performed on the DBAPI cursor; the
+ existing transaction remains in effect as well as any state
+ on the cursor.
+
+ The use case here is to inject low-level exception handling
+ into an :class:`.Engine`, typically for logging and
+ debugging purposes. In general, user code should **not** modify
+ any state or throw any exceptions here as this will
+ interfere with SQLAlchemy's cleanup and error handling
+ routines.
+
+ Subsequent to this hook, SQLAlchemy may attempt any
+ number of operations on the connection/cursor, including
+ closing the cursor, rolling back of the transaction in the
+ case of connectionless execution, and disposing of the entire
+ connection pool if a "disconnect" was detected. The
+ exception is then wrapped in a SQLAlchemy DBAPI exception
+ wrapper and re-thrown.
+
+ New in 0.7.7.
+
+ """
+
def begin(self, conn):
"""Intercept begin() events."""