Remove Elixir library
Update SQLAlchemy
This commit is contained in:
+409
-63
@@ -1,20 +1,20 @@
|
||||
# sqlalchemy/events.py
|
||||
# Copyright (C) 2005-2013 the SQLAlchemy authors and contributors <see AUTHORS file>
|
||||
# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors <see AUTHORS file>
|
||||
#
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
"""Core event interfaces."""
|
||||
|
||||
from sqlalchemy import event, exc, util
|
||||
engine = util.importlater('sqlalchemy', 'engine')
|
||||
pool = util.importlater('sqlalchemy', 'pool')
|
||||
|
||||
from . import event, exc
|
||||
from .pool import Pool
|
||||
from .engine import Connectable, Engine
|
||||
from .sql.base import SchemaEventTarget
|
||||
|
||||
class DDLEvents(event.Events):
|
||||
"""
|
||||
Define event listeners for schema objects,
|
||||
that is, :class:`.SchemaItem` and :class:`.SchemaEvent`
|
||||
that is, :class:`.SchemaItem` and other :class:`.SchemaEventTarget`
|
||||
subclasses, including :class:`.MetaData`, :class:`.Table`,
|
||||
:class:`.Column`.
|
||||
|
||||
@@ -70,6 +70,9 @@ class DDLEvents(event.Events):
|
||||
|
||||
"""
|
||||
|
||||
_target_class_doc = "SomeSchemaClassOrObject"
|
||||
_dispatch_target = SchemaEventTarget
|
||||
|
||||
def before_create(self, target, connection, **kw):
|
||||
"""Called before CREATE statments are emitted.
|
||||
|
||||
@@ -166,7 +169,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 +191,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 +203,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"
|
||||
# ...
|
||||
|
||||
@@ -216,23 +219,7 @@ class DDLEvents(event.Events):
|
||||
|
||||
"""
|
||||
|
||||
class SchemaEventTarget(object):
|
||||
"""Base class for elements that are the targets of :class:`.DDLEvents` events.
|
||||
|
||||
This includes :class:`.SchemaItem` as well as :class:`.SchemaType`.
|
||||
|
||||
"""
|
||||
dispatch = event.dispatcher(DDLEvents)
|
||||
|
||||
def _set_parent(self, parent):
|
||||
"""Associate with this SchemaEvent's parent object."""
|
||||
|
||||
raise NotImplementedError()
|
||||
|
||||
def _set_parent_with_dispatch(self, parent):
|
||||
self.dispatch.before_parent_attach(self, parent)
|
||||
self._set_parent(parent)
|
||||
self.dispatch.after_parent_attach(self, parent)
|
||||
|
||||
class PoolEvents(event.Events):
|
||||
"""Available events for :class:`.Pool`.
|
||||
@@ -250,11 +237,11 @@ class PoolEvents(event.Events):
|
||||
|
||||
event.listen(Pool, 'checkout', my_on_checkout)
|
||||
|
||||
In addition to accepting the :class:`.Pool` class and :class:`.Pool` instances,
|
||||
:class:`.PoolEvents` also accepts :class:`.Engine` objects and
|
||||
the :class:`.Engine` class as targets, which will be resolved
|
||||
to the ``.pool`` attribute of the given engine or the :class:`.Pool`
|
||||
class::
|
||||
In addition to accepting the :class:`.Pool` class and
|
||||
:class:`.Pool` instances, :class:`.PoolEvents` also accepts
|
||||
:class:`.Engine` objects and the :class:`.Engine` class as
|
||||
targets, which will be resolved to the ``.pool`` attribute of the
|
||||
given engine or the :class:`.Pool` class::
|
||||
|
||||
engine = create_engine("postgresql://scott:tiger@localhost/test")
|
||||
|
||||
@@ -263,14 +250,17 @@ class PoolEvents(event.Events):
|
||||
|
||||
"""
|
||||
|
||||
_target_class_doc = "SomeEngineOrPool"
|
||||
_dispatch_target = Pool
|
||||
|
||||
@classmethod
|
||||
def _accept_with(cls, target):
|
||||
if isinstance(target, type):
|
||||
if issubclass(target, engine.Engine):
|
||||
return pool.Pool
|
||||
elif issubclass(target, pool.Pool):
|
||||
if issubclass(target, Engine):
|
||||
return Pool
|
||||
elif issubclass(target, Pool):
|
||||
return target
|
||||
elif isinstance(target, engine.Engine):
|
||||
elif isinstance(target, Engine):
|
||||
return target.pool
|
||||
else:
|
||||
return target
|
||||
@@ -316,6 +306,10 @@ class PoolEvents(event.Events):
|
||||
connection will be disposed and a fresh connection retrieved.
|
||||
Processing of all checkout listeners will abort and restart
|
||||
using the new connection.
|
||||
|
||||
.. seealso:: :meth:`.ConnectionEvents.engine_connect` - a similar event
|
||||
which occurs upon creation of a new :class:`.Connection`.
|
||||
|
||||
"""
|
||||
|
||||
def checkin(self, dbapi_connection, connection_record):
|
||||
@@ -333,22 +327,95 @@ class PoolEvents(event.Events):
|
||||
|
||||
"""
|
||||
|
||||
def reset(self, dbapi_con, con_record):
|
||||
"""Called before the "reset" action occurs for a pooled connection.
|
||||
|
||||
This event represents
|
||||
when the ``rollback()`` method is called on the DBAPI connection
|
||||
before it is returned to the pool. The behavior of "reset" can
|
||||
be controlled, including disabled, using the ``reset_on_return``
|
||||
pool argument.
|
||||
|
||||
|
||||
The :meth:`.PoolEvents.reset` event is usually followed by the
|
||||
the :meth:`.PoolEvents.checkin` event is called, except in those
|
||||
cases where the connection is discarded immediately after reset.
|
||||
|
||||
:param dbapi_con:
|
||||
A raw DB-API connection
|
||||
|
||||
:param con_record:
|
||||
The ``_ConnectionRecord`` that persistently manages the connection
|
||||
|
||||
.. versionadded:: 0.8
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`.ConnectionEvents.rollback`
|
||||
|
||||
:meth:`.ConnectionEvents.commit`
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class ConnectionEvents(event.Events):
|
||||
"""Available events for :class:`.Connection`.
|
||||
"""Available events for :class:`.Connectable`, which includes
|
||||
:class:`.Connection` and :class:`.Engine`.
|
||||
|
||||
The methods here define the name of an event as well as the names of members that are passed to listener functions.
|
||||
The methods here define the name of an event as well as the names of
|
||||
members that are passed to listener functions.
|
||||
|
||||
e.g.::
|
||||
An event listener can be associated with any :class:`.Connectable`
|
||||
class or instance, such as an :class:`.Engine`, e.g.::
|
||||
|
||||
from sqlalchemy import event, create_engine
|
||||
|
||||
def before_execute(conn, clauseelement, multiparams, params):
|
||||
log.info("Received statement: %s" % clauseelement)
|
||||
def before_cursor_execute(conn, cursor, statement, parameters, context,
|
||||
executemany):
|
||||
log.info("Received statement: %s" % statement)
|
||||
|
||||
engine = create_engine('postgresql://scott:tiger@localhost/test')
|
||||
event.listen(engine, "before_execute", before_execute)
|
||||
event.listen(engine, "before_cursor_execute", before_cursor_execute)
|
||||
|
||||
Some events allow modifiers to the listen() function.
|
||||
or with a specific :class:`.Connection`::
|
||||
|
||||
with engine.begin() as conn:
|
||||
@event.listens_for(conn, 'before_cursor_execute')
|
||||
def before_cursor_execute(conn, cursor, statement, parameters,
|
||||
context, executemany):
|
||||
log.info("Received statement: %s" % statement)
|
||||
|
||||
The :meth:`.before_execute` and :meth:`.before_cursor_execute`
|
||||
events can also be established with the ``retval=True`` flag, which
|
||||
allows modification of the statement and parameters to be sent
|
||||
to the database. The :meth:`.before_cursor_execute` event is
|
||||
particularly useful here to add ad-hoc string transformations, such
|
||||
as comments, to all executions::
|
||||
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy import event
|
||||
|
||||
@event.listens_for(Engine, "before_cursor_execute", retval=True)
|
||||
def comment_sql_calls(conn, cursor, statement, parameters,
|
||||
context, executemany):
|
||||
statement = statement + " -- some comment"
|
||||
return statement, parameters
|
||||
|
||||
.. note:: :class:`.ConnectionEvents` can be established on any
|
||||
combination of :class:`.Engine`, :class:`.Connection`, as well
|
||||
as instances of each of those classes. Events across all
|
||||
four scopes will fire off for a given instance of
|
||||
:class:`.Connection`. However, for performance reasons, the
|
||||
:class:`.Connection` object determines at instantiation time
|
||||
whether or not its parent :class:`.Engine` has event listeners
|
||||
established. Event listeners added to the :class:`.Engine`
|
||||
class or to an instance of :class:`.Engine` *after* the instantiation
|
||||
of a dependent :class:`.Connection` instance will usually
|
||||
*not* be available on that :class:`.Connection` instance. The newly
|
||||
added listeners will instead take effect for :class:`.Connection`
|
||||
instances created subsequent to those event listeners being
|
||||
established on the parent :class:`.Engine` class or instance.
|
||||
|
||||
:param retval=False: Applies to the :meth:`.before_execute` and
|
||||
:meth:`.before_cursor_execute` events only. When True, the
|
||||
@@ -357,49 +424,153 @@ class ConnectionEvents(event.Events):
|
||||
and parameters. See those methods for a description of
|
||||
specific return arguments.
|
||||
|
||||
.. versionchanged:: 0.8 :class:`.ConnectionEvents` can now be associated
|
||||
with any :class:`.Connectable` including :class:`.Connection`,
|
||||
in addition to the existing support for :class:`.Engine`.
|
||||
|
||||
"""
|
||||
|
||||
_target_class_doc = "SomeEngine"
|
||||
_dispatch_target = Connectable
|
||||
|
||||
|
||||
@classmethod
|
||||
def _listen(cls, target, identifier, fn, retval=False):
|
||||
def _listen(cls, event_key, retval=False):
|
||||
target, identifier, fn = \
|
||||
event_key.dispatch_target, event_key.identifier, event_key.fn
|
||||
|
||||
target._has_events = True
|
||||
|
||||
if not retval:
|
||||
if identifier == 'before_execute':
|
||||
orig_fn = fn
|
||||
def wrap(conn, clauseelement, multiparams, params):
|
||||
|
||||
def wrap_before_execute(conn, clauseelement,
|
||||
multiparams, params):
|
||||
orig_fn(conn, clauseelement, multiparams, params)
|
||||
return clauseelement, multiparams, params
|
||||
fn = wrap
|
||||
fn = wrap_before_execute
|
||||
elif identifier == 'before_cursor_execute':
|
||||
orig_fn = fn
|
||||
def wrap(conn, cursor, statement,
|
||||
|
||||
def wrap_before_cursor_execute(conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
orig_fn(conn, cursor, statement,
|
||||
parameters, context, executemany)
|
||||
return statement, parameters
|
||||
fn = wrap
|
||||
fn = wrap_before_cursor_execute
|
||||
|
||||
elif retval and identifier not in ('before_execute', 'before_cursor_execute'):
|
||||
elif retval and \
|
||||
identifier not in ('before_execute', 'before_cursor_execute'):
|
||||
raise exc.ArgumentError(
|
||||
"Only the 'before_execute' and "
|
||||
"'before_cursor_execute' engine "
|
||||
"event listeners accept the 'retval=True' "
|
||||
"argument.")
|
||||
event.Events._listen(target, identifier, fn)
|
||||
event_key.with_wrapper(fn).base_listen()
|
||||
|
||||
def before_execute(self, conn, clauseelement, multiparams, params):
|
||||
"""Intercept high level execute() events."""
|
||||
"""Intercept high level execute() events, receiving uncompiled
|
||||
SQL constructs and other objects prior to rendering into SQL.
|
||||
|
||||
This event is good for debugging SQL compilation issues as well
|
||||
as early manipulation of the parameters being sent to the database,
|
||||
as the parameter lists will be in a consistent format here.
|
||||
|
||||
This event can be optionally established with the ``retval=True``
|
||||
flag. The ``clauseelement``, ``multiparams``, and ``params``
|
||||
arguments should be returned as a three-tuple in this case::
|
||||
|
||||
@event.listens_for(Engine, "before_execute", retval=True)
|
||||
def before_execute(conn, conn, clauseelement, multiparams, params):
|
||||
# do something with clauseelement, multiparams, params
|
||||
return clauseelement, multiparams, params
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param clauseelement: SQL expression construct, :class:`.Compiled`
|
||||
instance, or string statement passed to :meth:`.Connection.execute`.
|
||||
:param multiparams: Multiple parameter sets, a list of dictionaries.
|
||||
:param params: Single parameter set, a single dictionary.
|
||||
|
||||
See also:
|
||||
|
||||
:meth:`.before_cursor_execute`
|
||||
|
||||
"""
|
||||
|
||||
def after_execute(self, conn, clauseelement, multiparams, params, result):
|
||||
"""Intercept high level execute() events."""
|
||||
"""Intercept high level execute() events after execute.
|
||||
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param clauseelement: SQL expression construct, :class:`.Compiled`
|
||||
instance, or string statement passed to :meth:`.Connection.execute`.
|
||||
:param multiparams: Multiple parameter sets, a list of dictionaries.
|
||||
:param params: Single parameter set, a single dictionary.
|
||||
:param result: :class:`.ResultProxy` generated by the execution.
|
||||
|
||||
"""
|
||||
|
||||
def before_cursor_execute(self, conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
"""Intercept low-level cursor execute() events."""
|
||||
"""Intercept low-level cursor execute() events before execution,
|
||||
receiving the string
|
||||
SQL statement and DBAPI-specific parameter list to be invoked
|
||||
against a cursor.
|
||||
|
||||
This event is a good choice for logging as well as late modifications
|
||||
to the SQL string. It's less ideal for parameter modifications except
|
||||
for those which are specific to a target backend.
|
||||
|
||||
This event can be optionally established with the ``retval=True``
|
||||
flag. The ``statement`` and ``parameters`` arguments should be
|
||||
returned as a two-tuple in this case::
|
||||
|
||||
@event.listens_for(Engine, "before_cursor_execute", retval=True)
|
||||
def before_cursor_execute(conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
# do something with statement, parameters
|
||||
return statement, parameters
|
||||
|
||||
See the example at :class:`.ConnectionEvents`.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param cursor: DBAPI cursor object
|
||||
:param statement: string SQL statement
|
||||
:param parameters: Dictionary, tuple, or list of parameters being
|
||||
passed to the ``execute()`` or ``executemany()`` method of the
|
||||
DBAPI ``cursor``. In some cases may be ``None``.
|
||||
:param context: :class:`.ExecutionContext` object in use. May
|
||||
be ``None``.
|
||||
:param executemany: boolean, if ``True``, this is an ``executemany()``
|
||||
call, if ``False``, this is an ``execute()`` call.
|
||||
|
||||
See also:
|
||||
|
||||
:meth:`.before_execute`
|
||||
|
||||
:meth:`.after_cursor_execute`
|
||||
|
||||
"""
|
||||
|
||||
def after_cursor_execute(self, conn, cursor, statement,
|
||||
parameters, context, executemany):
|
||||
"""Intercept low-level cursor execute() events."""
|
||||
"""Intercept low-level cursor execute() events after execution.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param cursor: DBAPI cursor object. Will have results pending
|
||||
if the statement was a SELECT, but these should not be consumed
|
||||
as they will be needed by the :class:`.ResultProxy`.
|
||||
:param statement: string SQL statement
|
||||
:param parameters: Dictionary, tuple, or list of parameters being
|
||||
passed to the ``execute()`` or ``executemany()`` method of the
|
||||
DBAPI ``cursor``. In some cases may be ``None``.
|
||||
:param context: :class:`.ExecutionContext` object in use. May
|
||||
be ``None``.
|
||||
:param executemany: boolean, if ``True``, this is an ``executemany()``
|
||||
call, if ``False``, this is an ``execute()`` call.
|
||||
|
||||
"""
|
||||
|
||||
def dbapi_error(self, conn, cursor, statement, parameters,
|
||||
context, exception):
|
||||
@@ -427,37 +598,212 @@ class ConnectionEvents(event.Events):
|
||||
exception is then wrapped in a SQLAlchemy DBAPI exception
|
||||
wrapper and re-thrown.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param cursor: DBAPI cursor object
|
||||
:param statement: string SQL statement
|
||||
:param parameters: Dictionary, tuple, or list of parameters being
|
||||
passed to the ``execute()`` or ``executemany()`` method of the
|
||||
DBAPI ``cursor``. In some cases may be ``None``.
|
||||
:param context: :class:`.ExecutionContext` object in use. May
|
||||
be ``None``.
|
||||
:param exception: The **unwrapped** exception emitted directly from the
|
||||
DBAPI. The class here is specific to the DBAPI module in use.
|
||||
|
||||
.. versionadded:: 0.7.7
|
||||
|
||||
"""
|
||||
|
||||
def engine_connect(self, conn, branch):
|
||||
"""Intercept the creation of a new :class:`.Connection`.
|
||||
|
||||
This event is called typically as the direct result of calling
|
||||
the :meth:`.Engine.connect` method.
|
||||
|
||||
It differs from the :meth:`.PoolEvents.connect` method, which
|
||||
refers to the actual connection to a database at the DBAPI level;
|
||||
a DBAPI connection may be pooled and reused for many operations.
|
||||
In contrast, this event refers only to the production of a higher level
|
||||
:class:`.Connection` wrapper around such a DBAPI connection.
|
||||
|
||||
It also differs from the :meth:`.PoolEvents.checkout` event
|
||||
in that it is specific to the :class:`.Connection` object, not the
|
||||
DBAPI connection that :meth:`.PoolEvents.checkout` deals with, although
|
||||
this DBAPI connection is available here via the :attr:`.Connection.connection`
|
||||
attribute. But note there can in fact
|
||||
be multiple :meth:`.PoolEvents.checkout` events within the lifespan
|
||||
of a single :class:`.Connection` object, if that :class:`.Connection`
|
||||
is invalidated and re-established. There can also be multiple
|
||||
:class:`.Connection` objects generated for the same already-checked-out
|
||||
DBAPI connection, in the case that a "branch" of a :class:`.Connection`
|
||||
is produced.
|
||||
|
||||
:param conn: :class:`.Connection` object.
|
||||
:param branch: if True, this is a "branch" of an existing
|
||||
:class:`.Connection`. A branch is generated within the course
|
||||
of a statement execution to invoke supplemental statements, most
|
||||
typically to pre-execute a SELECT of a default value for the purposes
|
||||
of an INSERT statement.
|
||||
|
||||
.. versionadded:: 0.9.0
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`.PoolEvents.checkout` the lower-level pool checkout event
|
||||
for an individual DBAPI connection
|
||||
|
||||
:meth:`.ConnectionEvents.set_connection_execution_options` - a copy of a
|
||||
:class:`.Connection` is also made when the
|
||||
:meth:`.Connection.execution_options` method is called.
|
||||
|
||||
"""
|
||||
|
||||
def set_connection_execution_options(self, conn, opts):
|
||||
"""Intercept when the :meth:`.Connection.execution_options`
|
||||
method is called.
|
||||
|
||||
This method is called after the new :class:`.Connection` has been
|
||||
produced, with the newly updated execution options collection, but
|
||||
before the :class:`.Dialect` has acted upon any of those new options.
|
||||
|
||||
Note that this method is not called when a new :class:`.Connection`
|
||||
is produced which is inheriting execution options from its parent
|
||||
:class:`.Engine`; to intercept this condition, use the
|
||||
:meth:`.ConnectionEvents.engine_connect` event.
|
||||
|
||||
:param conn: The newly copied :class:`.Connection` object
|
||||
|
||||
:param opts: dictionary of options that were passed to the
|
||||
:meth:`.Connection.execution_options` method.
|
||||
|
||||
.. versionadded:: 0.9.0
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`.ConnectionEvents.set_engine_execution_options` - event
|
||||
which is called when :meth:`.Engine.execution_options` is called.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
def set_engine_execution_options(self, engine, opts):
|
||||
"""Intercept when the :meth:`.Engine.execution_options`
|
||||
method is called.
|
||||
|
||||
The :meth:`.Engine.execution_options` method produces a shallow
|
||||
copy of the :class:`.Engine` which stores the new options. That new
|
||||
:class:`.Engine` is passed here. A particular application of this
|
||||
method is to add a :meth:`.ConnectionEvents.engine_connect` event
|
||||
handler to the given :class:`.Engine` which will perform some per-
|
||||
:class:`.Connection` task specific to these execution options.
|
||||
|
||||
:param conn: The newly copied :class:`.Engine` object
|
||||
|
||||
:param opts: dictionary of options that were passed to the
|
||||
:meth:`.Connection.execution_options` method.
|
||||
|
||||
.. versionadded:: 0.9.0
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`.ConnectionEvents.set_connection_execution_options` - event
|
||||
which is called when :meth:`.Connection.execution_options` is called.
|
||||
|
||||
"""
|
||||
|
||||
def begin(self, conn):
|
||||
"""Intercept begin() events."""
|
||||
"""Intercept begin() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
|
||||
"""
|
||||
|
||||
def rollback(self, conn):
|
||||
"""Intercept rollback() events."""
|
||||
"""Intercept rollback() events, as initiated by a
|
||||
:class:`.Transaction`.
|
||||
|
||||
Note that the :class:`.Pool` also "auto-rolls back"
|
||||
a DBAPI connection upon checkin, if the ``reset_on_return``
|
||||
flag is set to its default value of ``'rollback'``.
|
||||
To intercept this
|
||||
rollback, use the :meth:`.PoolEvents.reset` hook.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
|
||||
.. seealso::
|
||||
|
||||
:meth:`.PoolEvents.reset`
|
||||
|
||||
"""
|
||||
|
||||
def commit(self, conn):
|
||||
"""Intercept commit() events."""
|
||||
"""Intercept commit() events, as initiated by a
|
||||
:class:`.Transaction`.
|
||||
|
||||
def savepoint(self, conn, name=None):
|
||||
"""Intercept savepoint() events."""
|
||||
Note that the :class:`.Pool` may also "auto-commit"
|
||||
a DBAPI connection upon checkin, if the ``reset_on_return``
|
||||
flag is set to the value ``'commit'``. To intercept this
|
||||
commit, use the :meth:`.PoolEvents.reset` hook.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
"""
|
||||
|
||||
def savepoint(self, conn, name):
|
||||
"""Intercept savepoint() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param name: specified name used for the savepoint.
|
||||
|
||||
"""
|
||||
|
||||
def rollback_savepoint(self, conn, name, context):
|
||||
"""Intercept rollback_savepoint() events."""
|
||||
"""Intercept rollback_savepoint() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param name: specified name used for the savepoint.
|
||||
:param context: :class:`.ExecutionContext` in use. May be ``None``.
|
||||
|
||||
"""
|
||||
|
||||
def release_savepoint(self, conn, name, context):
|
||||
"""Intercept release_savepoint() events."""
|
||||
"""Intercept release_savepoint() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param name: specified name used for the savepoint.
|
||||
:param context: :class:`.ExecutionContext` in use. May be ``None``.
|
||||
|
||||
"""
|
||||
|
||||
def begin_twophase(self, conn, xid):
|
||||
"""Intercept begin_twophase() events."""
|
||||
"""Intercept begin_twophase() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param xid: two-phase XID identifier
|
||||
|
||||
"""
|
||||
|
||||
def prepare_twophase(self, conn, xid):
|
||||
"""Intercept prepare_twophase() events."""
|
||||
"""Intercept prepare_twophase() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param xid: two-phase XID identifier
|
||||
"""
|
||||
|
||||
def rollback_twophase(self, conn, xid, is_prepared):
|
||||
"""Intercept rollback_twophase() events."""
|
||||
"""Intercept rollback_twophase() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param xid: two-phase XID identifier
|
||||
:param is_prepared: boolean, indicates if
|
||||
:meth:`.TwoPhaseTransaction.prepare` was called.
|
||||
|
||||
"""
|
||||
|
||||
def commit_twophase(self, conn, xid, is_prepared):
|
||||
"""Intercept commit_twophase() events."""
|
||||
"""Intercept commit_twophase() events.
|
||||
|
||||
:param conn: :class:`.Connection` object
|
||||
:param xid: two-phase XID identifier
|
||||
:param is_prepared: boolean, indicates if
|
||||
:meth:`.TwoPhaseTransaction.prepare` was called.
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user