The oslo_db.sqlalchemy.compat.handle_error
Module¶
Provide forwards compatibility for the handle_error event.
See the “handle_error” event at http://docs.sqlalchemy.org/en/rel_0_9/core/events.html.
-
class
oslo_db.sqlalchemy.compat.handle_error.
ExceptionContextImpl
(exception, sqlalchemy_exception, engine, connection, cursor, statement, parameters, context, is_disconnect)¶ Bases:
object
Encapsulate information about an error condition in progress.
This is for forwards compatibility with the ExceptionContext interface introduced in SQLAlchemy 0.9.7.
It also provides for the “engine” argument added in SQLAlchemy 1.0.0.
-
chained_exception
= None¶ The exception that was returned by the previous handler in the exception chain, if any.
If present, this exception will be the one ultimately raised by SQLAlchemy unless a subsequent handler replaces it.
May be None.
-
connection
= None¶ The
Connection
in use during the exception.This member is present, except in the case of a failure when first connecting.
-
cursor
= None¶ The DBAPI cursor object.
May be None.
-
engine
= None¶ The
Engine
in use during the exception.This member should always be present, even in the case of a failure when first connecting.
-
execution_context
= None¶ The
ExecutionContext
corresponding to the execution operation in progress.This is present for statement execution operations, but not for operations such as transaction begin/end. It also is not present when the exception was raised before the
ExecutionContext
could be constructed.Note that the
ExceptionContext.statement
andExceptionContext.parameters
members may represent a different value than that of theExecutionContext
, potentially in the case where aConnectionEvents.before_cursor_execute()
event or similar modified the statement/parameters to be sent.May be None.
-
is_disconnect
= None¶ Represent whether the exception as occurred represents a “disconnect” condition.
This flag will always be True or False within the scope of the
ConnectionEvents.handle_error()
handler.
-
original_exception
= None¶ The exception object which was caught.
This member is always present.
-
parameters
= None¶ Parameter collection that was emitted directly to the DBAPI.
May be None.
-
sqlalchemy_exception
= None¶ The
sqlalchemy.exc.StatementError
which wraps the original, and will be raised if exception handling is not circumvented by the event.May be None, as not all exception types are wrapped by SQLAlchemy. For DBAPI-level exceptions that subclass the dbapi’s Error class, this field will always be present.
-
statement
= None¶ String SQL statement that was emitted directly to the DBAPI.
May be None.
-
-
oslo_db.sqlalchemy.compat.handle_error.
handle_error
(engine, listener)¶ Add a handle_error listener for the given
Engine
.This listener uses the SQLAlchemy
sqlalchemy.event.ConnectionEvents.handle_error()
event.