
    ,h                      % S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSK J"r"  SS K J#r#  SS!K Jr  SS"K$J%r%  SS!K$Jr&  \RN                  (       a  SS#K J(r(  SS$K J)r)  SS%KJ*r*  SS&KJ+r+  SS'KJ,r,  SS(KJ-r-  SS)KJ.r.  SS*KJ/r/  SS+KJ0r0  SS,KJ1r1  SS-KJ2r2  SS.KJ3r3  SS/KJ4r4  SS0KJ5r5  SS1K6J7r7  SS2K8J9r9  SS3K:J;r;  SS4K#J<r<  SS5K=J>r>  SS6K=J?r?  SS7K=J@r@  SS8K$JArA  SS9KBJCrC  SS:KDJErE  SS;KFJGrG  SS<KFJHrH  SS=KIJJrJ  SS>KKJLrL  SS?KKJMrM  SS@KKJNrN  SSAKOJPrP  \" SB\SC9rQ\R                  rSSD\TSE'   \R                  rUSF\TSG'    " SH SI\\"R                  SJ   5      rW " SK SL\5      rX " SM SN\5      rY " SO SP\Y5      rZ " SQ SR\Y5      r[ " SS ST\Z5      r\ " SU SV\\#R                  \"R                  SJ   5      r^ " SW SX\#R                  5      r_ " SY SZ\_\^5      r`\`\^la        g)[zBDefines :class:`_engine.Connection` and :class:`_engine.Engine`.

    )annotationsN)Any)Callable)cast)Iterable)Iterator)List)Mapping)NoReturn)Optional)overload)Tuple)Type)TypeVar)Union   )
BindTyping)ConnectionEventsTarget)DBAPICursor)ExceptionContext)ExecuteStyle)ExecutionContext)IsolationLevel)_distill_params_20)_distill_raw_params)TransactionalContext   )exc)
inspection)log)util)compiler)CursorResult)ScalarResult)_AnyExecuteParams)_AnyMultiExecuteParams)_CoreAnyExecuteParams)_CoreMultiExecuteParams)_CoreSingleExecuteParams)_DBAPIAnyExecuteParams)_DBAPISingleExecuteParams)_ExecuteOptions)CompiledCacheType)CoreExecuteOptionsParameter)Dialect)SchemaTranslateMapType)	Inspector)URL)
dispatcher)_EchoFlagType)_ConnectionFairy)Pool)PoolProxiedConnection)
Executable)	_InfoType)Compiled)ExecutableDDLElement)InvokeDDLBase)FunctionElement)DefaultGenerator)HasSchemaAttr)SchemaVisitable)TypedReturnsRows_T)boundr,   _EMPTY_EXECUTION_OPTSzMapping[str, Any]
NO_OPTIONSc                     \ rS rSr% SrS\S'   S\S'   SrSrS	\S
'   SrS\S'   S\S'   S\S'   S\S'       Sc         SdS jjr	Sr
S\S'   SeS jrSeS jr\SfS j5       rSgS jrShS jrSiS jr\SSSSSSSSSSS.
                       SjS jj5       r\SkS  j5       rSkS! jrSlS" jr\SmS# j5       r\SmS$ j5       r\SmS% j5       r\SnS& j5       rSoS' jr\SpS( j5       rSqS) jrSnS* jr\SrS+ j5       rSsStS, jjrSuS- jrSuS. jr SvS/ jr!SwS0 jr"SsSxS1 jjr#SuS2 jr$SuS3 jr%SyS4 jr&SzS{S5 jjr'SzS{S6 jjr(SmS7 jr)SmS8 jr*SmS9 jr+SvS: jr,SwS; jr-S|S< jr.S}S= jr/S~S> jr0SuS? jr1SuS@ jr2SsSSA jjr3SSB jr4SSC jr5SSD jr6SSE jr7SSF jr8SSG jr9SuSH jr:\ SsSSI.       SSJ jjj5       r;\ SsSSI.       SSK jjj5       r; SsSSI.       SSL jjjr;\ SsSSI.       SSM jjj5       r<\ SsSSI.       SSN jjj5       r< SsSSI.       SSO jjjr<\ SsSSI.       SSP jjj5       r=\ SsSSI.       SSQ jjj5       r= SsSSI.       SSR jjjr=        SSS jr>        SST jr?        SSU jr@        SSV jrA        SSW jrB\C4       SSX jjrD  S       SSY jjrE                SSZ jrF          SS[ jrG      SS\ jrH Ss         SS] jjrISS^ jrJSrKSrL Sz             SS_ jjrM\N    S             SS` jj5       rO        SSa jrPSbrQg)
ConnectionV   a  Provides high-level functionality for a wrapped DB-API connection.

The :class:`_engine.Connection` object is procured by calling the
:meth:`_engine.Engine.connect` method of the :class:`_engine.Engine`
object, and provides services for execution of SQL statements as well
as transaction control.

The Connection object is **not** thread-safe. While a Connection can be
shared among threads using properly synchronized access, it is still
possible that the underlying DBAPI connection may not support shared
access between threads. Check the DBAPI documentation for details.

The Connection object represents a single DBAPI connection checked out
from the connection pool. In this state, the connection pool has no
affect upon the connection, including its expiration or timeout state.
For the connection pool to properly manage connections, connections
should be returned to the connection pool (i.e. ``connection.close()``)
whenever the connection is not in use.

.. index::
  single: thread safety; Connection

r/   dialect"dispatcher[ConnectionEventsTarget]dispatchzsqlalchemy.engine.ConnectionNzOptional[TransactionalContext]_trans_context_managerFOptional[PoolProxiedConnection]_dbapi_connectionr,   _execution_optionsOptional[RootTransaction]_transactionOptional[NestedTransaction]_nested_transactionc                   Xl         UR                  =U l        nUc   UR                  5       U l        OX l        S=U l        U l	        SU l
        SU l        X@l        XPl        U R                   R                  5       U l        Uc*  U R                   R#                  UR                   5      U l        U=(       d    USL =(       a    UR$                  U l        UR&                  U l        U R$                  (       d  U R                   R$                  (       a  U R                   R)                  U 5        gg! UR                  R
                   a  n[        R                  XvU5        e SnAff = f)zConstruct a new Connection.Nr   F)enginerI   raw_connectionrN   loaded_dbapiErrorrG   $_handle_dbapi_exception_noconnectionrQ   rS   _Connection__savepoint_seq_Connection__in_begin_Connection__can_reconnect_allow_autobegin_should_log_info_echorK   _join_has_eventsrO   engine_connect)selfrU   
connectionra   _allow_revalidater]   rI   errs           N/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/engine/base.py__init__Connection.__init__   s3    !'/w)/)>)>)@& &0"7;;D4 0 0[[113
 !MM//@DM& 
46F$6$6 	 #)";";t{{66MM((.  77 ''-- ??& 	s   D- -E#EE#r   _message_formatterc                    U R                   nU(       a  U" U5      n[        R                  (       a  S[        R                  -   US'   U R                  R
                  R                  " U/UQ70 UD6  g Nr   
stacklevel)rj   r    
STACKLEVELSTACKLEVEL_OFFSETrU   loggerinforc   messageargkwfmts        rg   	_log_infoConnection._log_info   sW    %%'lG>> 3#8#88B|4#44    c                    U R                   nU(       a  U" U5      n[        R                  (       a  S[        R                  -   US'   U R                  R
                  R                  " U/UQ70 UD6  g rl   )rj   r    rn   ro   rU   rp   debugrr   s        rg   
_log_debugConnection._log_debug   sW    %%'lG>> 3#8#88B|  535"5ry   c                >    U R                   R                  SS 5      nU$ )Nschema_translate_map)rO   get)rc   r   s     rg   _schema_translate_map Connection._schema_translate_map   s(     ##''(>E 	 $#ry   c                    UR                   nU R                  R                  SS5      nU(       a  X#;   a  UR                  (       a  X2   $ U$ )zdReturn the schema name for the given schema item taking into
account current schema translate map.

r   N)schemarO   r   _use_schema_map)rc   objnamer   s       rg   schema_for_objectConnection.schema_for_object   sK     zz##''(>E 	
 !,##'--Kry   c                    U $ N rc   s    rg   	__enter__Connection.__enter__   s    ry   c                $    U R                  5         g r   )close)rc   type_value	tracebacks       rg   __exit__Connection.__exit__   s    

ry   .)
compiled_cachelogging_tokenisolation_levelno_parametersstream_resultsmax_row_buffer	yield_perinsertmanyvalues_page_sizer   preserve_rowcountc       
            g r   r   )rc   r   r   r   r   r   r   r   r   r   r   opts               rg   execution_optionsConnection.execution_options   s     ry   c                    g r   r   rc   r   s     rg   r   r      s    ;>ry   c                
   U R                   (       d  U R                  R                   (       a  U R                  R                  X5        U R                  R                  U5      U l        U R                  R                  X5        U $ )a*  Set non-SQL options for the connection which take effect
during execution.

This method modifies this :class:`_engine.Connection` **in-place**;
the return value is the same :class:`_engine.Connection` object
upon which the method is called.   Note that this is in contrast
to the behavior of the ``execution_options`` methods on other
objects such as :meth:`_engine.Engine.execution_options` and
:meth:`_sql.Executable.execution_options`.  The rationale is that many
such execution options necessarily modify the state of the base
DBAPI connection in any case so there is no feasible means of
keeping the effect of such an option localized to a "sub" connection.

.. versionchanged:: 2.0  The :meth:`_engine.Connection.execution_options`
   method, in contrast to other objects with this method, modifies
   the connection in-place without creating copy of it.

As discussed elsewhere, the :meth:`_engine.Connection.execution_options`
method accepts any arbitrary parameters including user defined names.
All parameters given are consumable in a number of ways including
by using the :meth:`_engine.Connection.get_execution_options` method.
See the examples at :meth:`_sql.Executable.execution_options`
and :meth:`_engine.Engine.execution_options`.

The keywords that are currently recognized by SQLAlchemy itself
include all those listed under :meth:`.Executable.execution_options`,
as well as others that are specific to :class:`_engine.Connection`.

:param compiled_cache: Available on: :class:`_engine.Connection`,
  :class:`_engine.Engine`.

  A dictionary where :class:`.Compiled` objects
  will be cached when the :class:`_engine.Connection`
  compiles a clause
  expression into a :class:`.Compiled` object.  This dictionary will
  supersede the statement cache that may be configured on the
  :class:`_engine.Engine` itself.   If set to None, caching
  is disabled, even if the engine has a configured cache size.

  Note that the ORM makes use of its own "compiled" caches for
  some operations, including flush operations.  The caching
  used by the ORM internally supersedes a cache dictionary
  specified here.

:param logging_token: Available on: :class:`_engine.Connection`,
  :class:`_engine.Engine`, :class:`_sql.Executable`.

  Adds the specified string token surrounded by brackets in log
  messages logged by the connection, i.e. the logging that's enabled
  either via the :paramref:`_sa.create_engine.echo` flag or via the
  ``logging.getLogger("sqlalchemy.engine")`` logger. This allows a
  per-connection or per-sub-engine token to be available which is
  useful for debugging concurrent connection scenarios.

  .. versionadded:: 1.4.0b2

  .. seealso::

    :ref:`dbengine_logging_tokens` - usage example

    :paramref:`_sa.create_engine.logging_name` - adds a name to the
    name used by the Python logger object itself.

:param isolation_level: Available on: :class:`_engine.Connection`,
  :class:`_engine.Engine`.

  Set the transaction isolation level for the lifespan of this
  :class:`_engine.Connection` object.
  Valid values include those string
  values accepted by the :paramref:`_sa.create_engine.isolation_level`
  parameter passed to :func:`_sa.create_engine`.  These levels are
  semi-database specific; see individual dialect documentation for
  valid levels.

  The isolation level option applies the isolation level by emitting
  statements on the DBAPI connection, and **necessarily affects the
  original Connection object overall**. The isolation level will remain
  at the given setting until explicitly changed, or when the DBAPI
  connection itself is :term:`released` to the connection pool, i.e. the
  :meth:`_engine.Connection.close` method is called, at which time an
  event handler will emit additional statements on the DBAPI connection
  in order to revert the isolation level change.

  .. note:: The ``isolation_level`` execution option may only be
     established before the :meth:`_engine.Connection.begin` method is
     called, as well as before any SQL statements are emitted which
     would otherwise trigger "autobegin", or directly after a call to
     :meth:`_engine.Connection.commit` or
     :meth:`_engine.Connection.rollback`. A database cannot change the
     isolation level on a transaction in progress.

  .. note:: The ``isolation_level`` execution option is implicitly
     reset if the :class:`_engine.Connection` is invalidated, e.g. via
     the :meth:`_engine.Connection.invalidate` method, or if a
     disconnection error occurs. The new connection produced after the
     invalidation will **not** have the selected isolation level
     re-applied to it automatically.

  .. seealso::

        :ref:`dbapi_autocommit`

        :meth:`_engine.Connection.get_isolation_level`
        - view current actual level

:param no_parameters: Available on: :class:`_engine.Connection`,
  :class:`_sql.Executable`.

  When ``True``, if the final parameter
  list or dictionary is totally empty, will invoke the
  statement on the cursor as ``cursor.execute(statement)``,
  not passing the parameter collection at all.
  Some DBAPIs such as psycopg2 and mysql-python consider
  percent signs as significant only when parameters are
  present; this option allows code to generate SQL
  containing percent signs (and possibly other characters)
  that is neutral regarding whether it's executed by the DBAPI
  or piped into a script that's later invoked by
  command line tools.

:param stream_results: Available on: :class:`_engine.Connection`,
  :class:`_sql.Executable`.

  Indicate to the dialect that results should be "streamed" and not
  pre-buffered, if possible.  For backends such as PostgreSQL, MySQL
  and MariaDB, this indicates the use of a "server side cursor" as
  opposed to a client side cursor.  Other backends such as that of
  Oracle Database may already use server side cursors by default.

  The usage of
  :paramref:`_engine.Connection.execution_options.stream_results` is
  usually combined with setting a fixed number of rows to to be fetched
  in batches, to allow for efficient iteration of database rows while
  at the same time not loading all result rows into memory at once;
  this can be configured on a :class:`_engine.Result` object using the
  :meth:`_engine.Result.yield_per` method, after execution has
  returned a new :class:`_engine.Result`.   If
  :meth:`_engine.Result.yield_per` is not used,
  the :paramref:`_engine.Connection.execution_options.stream_results`
  mode of operation will instead use a dynamically sized buffer
  which buffers sets of rows at a time, growing on each batch
  based on a fixed growth size up until a limit which may
  be configured using the
  :paramref:`_engine.Connection.execution_options.max_row_buffer`
  parameter.

  When using the ORM to fetch ORM mapped objects from a result,
  :meth:`_engine.Result.yield_per` should always be used with
  :paramref:`_engine.Connection.execution_options.stream_results`,
  so that the ORM does not fetch all rows into new ORM objects at once.

  For typical use, the
  :paramref:`_engine.Connection.execution_options.yield_per` execution
  option should be preferred, which sets up both
  :paramref:`_engine.Connection.execution_options.stream_results` and
  :meth:`_engine.Result.yield_per` at once. This option is supported
  both at a core level by :class:`_engine.Connection` as well as by the
  ORM :class:`_engine.Session`; the latter is described at
  :ref:`orm_queryguide_yield_per`.

  .. seealso::

    :ref:`engine_stream_results` - background on
    :paramref:`_engine.Connection.execution_options.stream_results`

    :paramref:`_engine.Connection.execution_options.max_row_buffer`

    :paramref:`_engine.Connection.execution_options.yield_per`

    :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel`
    describing the ORM version of ``yield_per``

:param max_row_buffer: Available on: :class:`_engine.Connection`,
  :class:`_sql.Executable`.  Sets a maximum
  buffer size to use when the
  :paramref:`_engine.Connection.execution_options.stream_results`
  execution option is used on a backend that supports server side
  cursors.  The default value if not specified is 1000.

  .. seealso::

    :paramref:`_engine.Connection.execution_options.stream_results`

    :ref:`engine_stream_results`


:param yield_per: Available on: :class:`_engine.Connection`,
  :class:`_sql.Executable`.  Integer value applied which will
  set the :paramref:`_engine.Connection.execution_options.stream_results`
  execution option and invoke :meth:`_engine.Result.yield_per`
  automatically at once.  Allows equivalent functionality as
  is present when using this parameter with the ORM.

  .. versionadded:: 1.4.40

  .. seealso::

    :ref:`engine_stream_results` - background and examples
    on using server side cursors with Core.

    :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel`
    describing the ORM version of ``yield_per``

:param insertmanyvalues_page_size: Available on: :class:`_engine.Connection`,
    :class:`_engine.Engine`. Number of rows to format into an
    INSERT statement when the statement uses "insertmanyvalues" mode,
    which is a paged form of bulk insert that is used for many backends
    when using :term:`executemany` execution typically in conjunction
    with RETURNING. Defaults to 1000. May also be modified on a
    per-engine basis using the
    :paramref:`_sa.create_engine.insertmanyvalues_page_size` parameter.

    .. versionadded:: 2.0

    .. seealso::

        :ref:`engine_insertmanyvalues`

:param schema_translate_map: Available on: :class:`_engine.Connection`,
  :class:`_engine.Engine`, :class:`_sql.Executable`.

  A dictionary mapping schema names to schema names, that will be
  applied to the :paramref:`_schema.Table.schema` element of each
  :class:`_schema.Table`
  encountered when SQL or DDL expression elements
  are compiled into strings; the resulting schema name will be
  converted based on presence in the map of the original name.

  .. seealso::

    :ref:`schema_translating`

:param preserve_rowcount: Boolean; when True, the ``cursor.rowcount``
  attribute will be unconditionally memoized within the result and
  made available via the :attr:`.CursorResult.rowcount` attribute.
  Normally, this attribute is only preserved for UPDATE and DELETE
  statements.  Using this option, the DBAPIs rowcount value can
  be accessed for other kinds of statements such as INSERT and SELECT,
  to the degree that the DBAPI supports these statements.  See
  :attr:`.CursorResult.rowcount` for notes regarding the behavior
  of this attribute.

  .. versionadded:: 2.0.28

.. seealso::

    :meth:`_engine.Engine.execution_options`

    :meth:`.Executable.execution_options`

    :meth:`_engine.Connection.get_execution_options`

    :ref:`orm_queryguide_execution_options` - documentation on all
    ORM-specific execution options

)ra   rU   rK    set_connection_execution_optionsrO   unionrI   r   s     rg   r   r      s\    B t{{66MM::4E"&"9"9"?"?"D55d@ry   c                    U R                   $ )zGet the non-SQL options which will take effect during execution.

.. versionadded:: 1.3

.. seealso::

    :meth:`_engine.Connection.execution_options`
rO   r   s    rg   get_execution_options Connection.get_execution_options       &&&ry   c                H    U R                   nUS L=(       a    UR                  $ r   )rN   is_validrc   pool_proxied_connections     rg   )_still_open_and_dbapi_connection_is_valid4Connection._still_open_and_dbapi_connection_is_valid  s)    "&"8"8#4/ 1'00	
ry   c                N    U R                   SL =(       a    U R                  (       + $ )z)Return True if this connection is closed.NrN   r\   r   s    rg   closedConnection.closed  s#     %%-Jd6J6J2JJry   c                H    U R                   nUSL =(       a    U R                  $ )zReturn True if this connection was invalidated.

This does not indicate whether or not the connection was
invalidated at the pool level, however

Nr   r   s     rg   invalidatedConnection.invalidated   s&    $ #'"8"8&$.G43G3GGry   c                    U R                   c   U R                  5       $ U R                   $ ! [        R                  [        R                  4 a    e [
         a  nU R                  USSSS5         SnAgSnAff = f)a  The underlying DB-API connection managed by this Connection.

This is a SQLAlchemy connection-pool proxied connection
which then has the attribute
:attr:`_pool._ConnectionFairy.dbapi_connection` that refers to the
actual driver connection.

.. seealso::


    :ref:`dbapi_connections`

N)rN   _revalidate_connectionr   PendingRollbackErrorResourceClosedErrorBaseException_handle_dbapi_exceptionrc   es     rg   rd   Connection.connection5  s|      !!)H2244 ))) ,,c.E.EF   H,,QdD$GGHs   + .A8A33A8c                    U R                   R                  nUc   e U R                  R                  U5      $ ! [         a  nU R                  USSSS5         SnAgSnAff = f)a  Return the current **actual** isolation level that's present on
the database within the scope of this connection.

This attribute will perform a live SQL operation against the database
in order to procure the current isolation level, so the value returned
is the actual level on the underlying DBAPI connection regardless of
how this state was set. This will be one of the four actual isolation
modes ``READ UNCOMMITTED``, ``READ COMMITTED``, ``REPEATABLE READ``,
``SERIALIZABLE``. It will **not** include the ``AUTOCOMMIT`` isolation
level setting. Third party dialects may also feature additional
isolation level settings.

.. note::  This method **will not report** on the ``AUTOCOMMIT``
  isolation level, which is a separate :term:`dbapi` setting that's
  independent of **actual** isolation level.  When ``AUTOCOMMIT`` is
  in use, the database connection still has a "traditional" isolation
  mode in effect, that is typically one of the four values
  ``READ UNCOMMITTED``, ``READ COMMITTED``, ``REPEATABLE READ``,
  ``SERIALIZABLE``.

Compare to the :attr:`_engine.Connection.default_isolation_level`
accessor which returns the isolation level that is present on the
database at initial connection time.

.. seealso::

    :attr:`_engine.Connection.default_isolation_level`
    - view default level

    :paramref:`_sa.create_engine.isolation_level`
    - set per :class:`_engine.Engine` isolation level

    :paramref:`.Connection.execution_options.isolation_level`
    - set per :class:`_engine.Connection` isolation level

N)rd   dbapi_connectionrI   get_isolation_levelr   r   )rc   r   r   s      rg   r   Connection.get_isolation_levelO  sh    J  ??;;+++	D<<334DEE 	D((D$dCC	Ds   8 
A!AA!c                .    U R                   R                  $ )an  The initial-connection time isolation level associated with the
:class:`_engine.Dialect` in use.

This value is independent of the
:paramref:`.Connection.execution_options.isolation_level` and
:paramref:`.Engine.execution_options.isolation_level` execution
options, and is determined by the :class:`_engine.Dialect` when the
first connection is created, by performing a SQL query against the
database for the current isolation level before any additional commands
have been emitted.

Calling this accessor does not invoke any new SQL queries.

.. seealso::

    :meth:`_engine.Connection.get_isolation_level`
    - view current actual isolation level

    :paramref:`_sa.create_engine.isolation_level`
    - set per :class:`_engine.Engine` isolation level

    :paramref:`.Connection.execution_options.isolation_level`
    - set per :class:`_engine.Connection` isolation level

)rI   default_isolation_levelr   s    rg   r   "Connection.default_isolation_level{  s    6 ||333ry   c                P    [         R                  " SU R                  b  SOS-  SS9e)NzfCan't reconnect until invalid %stransaction is rolled back.  Please rollback() fully before proceedingz
savepoint  8s2b)code)r   r   rS   r   s    rg   _invalid_transactionConnection._invalid_transaction  s5    &&?#77C|M 	
 	
ry   c                   U R                   (       aY  U R                  (       aH  U R                  b  U R                  5         U R                  R                  5       U l        U R                  $ [        R                  " S5      e)NThis Connection is closed)	r\   r   rQ   r   rU   rV   rN   r   r   r   s    rg   r   !Connection._revalidate_connection  s^    D$4$4  ,))+%)[[%?%?%AD")))%%&ABBry   c                .    U R                   R                  $ )ak  Info dictionary associated with the underlying DBAPI connection
referred to by this :class:`_engine.Connection`, allowing user-defined
data to be associated with the connection.

The data here will follow along with the DBAPI connection including
after it is returned to the connection pool and used again
in subsequent instances of :class:`_engine.Connection`.

)rd   rq   r   s    rg   rq   Connection.info  s     ###ry   c                    U R                   (       a  gU R                  (       a  [        R                  " S5      eU R                  (       a"  U R
                  nUc   eUR                  U5        SU l        g)a  Invalidate the underlying DBAPI connection associated with
this :class:`_engine.Connection`.

An attempt will be made to close the underlying DBAPI connection
immediately; however if this operation fails, the error is logged
but not raised.  The connection is then discarded whether or not
close() succeeded.

Upon the next use (where "use" typically means using the
:meth:`_engine.Connection.execute` method or similar),
this :class:`_engine.Connection` will attempt to
procure a new DBAPI connection using the services of the
:class:`_pool.Pool` as a source of connectivity (e.g.
a "reconnection").

If a transaction was in progress (e.g. the
:meth:`_engine.Connection.begin` method has been called) when
:meth:`_engine.Connection.invalidate` method is called, at the DBAPI
level all state associated with this transaction is lost, as
the DBAPI connection is closed.  The :class:`_engine.Connection`
will not allow a reconnection to proceed until the
:class:`.Transaction` object is ended, by calling the
:meth:`.Transaction.rollback` method; until that point, any attempt at
continuing to use the :class:`_engine.Connection` will raise an
:class:`~sqlalchemy.exc.InvalidRequestError`.
This is to prevent applications from accidentally
continuing an ongoing transactional operations despite the
fact that the transaction has been lost due to an
invalidation.

The :meth:`_engine.Connection.invalidate` method,
just like auto-invalidation,
will at the connection pool level invoke the
:meth:`_events.PoolEvents.invalidate` event.

:param exception: an optional ``Exception`` instance that's the
 reason for the invalidation.  is passed along to event handlers
 and logging functions.

.. seealso::

    :ref:`pool_connection_invalidation`

Nr   )r   r   r   r   r   rN   
invalidate)rc   	exceptionr   s      rg   r   Connection.invalidate  sa    \ ;;))*EFF99&*&<&<#*666#..y9!%ry   c                    U R                   (       a  [        R                  " S5      eU R                  nUc  [        R                  " S5      eUR                  5         g)a  Detach the underlying DB-API connection from its connection pool.

E.g.::

    with engine.connect() as conn:
        conn.detach()
        conn.execute(text("SET search_path TO schema1, schema2"))

        # work with connection

    # connection is fully closed (since we used "with:", can
    # also call .close())

This :class:`_engine.Connection` instance will remain usable.
When closed
(or exited from a context manager context as above),
the DB-API connection will be literally closed and not
returned to its originating pool.

This method can be used to insulate the rest of an application
from a modified state on a connection (such as a transaction
isolation level or similar).

r   Nz&Can't detach an invalidated Connection)r   r   r   rN   InvalidRequestErrordetachr   s     rg   r   Connection.detach  sS    4 ;;))*EFF"&"8"8"*))8  	 &&(ry   c                l    U R                   (       a#  U R                  (       d  U R                  5         g g g r   )r]   r[   beginr   s    rg   
_autobeginConnection._autobegin  s"      JJL *9 ry   c                    U R                   c  [        U 5      U l         U R                   $ [        R                  " S5      e)a)  Begin a transaction prior to autobegin occurring.

E.g.::

    with engine.connect() as conn:
        with conn.begin() as trans:
            conn.execute(table.insert(), {"username": "sandy"})

The returned object is an instance of :class:`_engine.RootTransaction`.
This object represents the "scope" of the transaction,
which completes when either the :meth:`_engine.Transaction.rollback`
or :meth:`_engine.Transaction.commit` method is called; the object
also works as a context manager as illustrated above.

The :meth:`_engine.Connection.begin` method begins a
transaction that normally will be begun in any case when the connection
is first used to execute a statement.  The reason this method might be
used would be to invoke the :meth:`_events.ConnectionEvents.begin`
event at a specific time, or to organize code within the scope of a
connection checkout in terms of context managed blocks, such as::

    with engine.connect() as conn:
        with conn.begin():
            conn.execute(...)
            conn.execute(...)

        with conn.begin():
            conn.execute(...)
            conn.execute(...)

The above code is not  fundamentally any different in its behavior than
the following code  which does not use
:meth:`_engine.Connection.begin`; the below style is known
as "commit as you go" style::

    with engine.connect() as conn:
        conn.execute(...)
        conn.execute(...)
        conn.commit()

        conn.execute(...)
        conn.execute(...)
        conn.commit()

From a database point of view, the :meth:`_engine.Connection.begin`
method does not emit any SQL or change the state of the underlying
DBAPI connection in any way; the Python DBAPI does not have any
concept of explicit transaction begin.

.. seealso::

    :ref:`tutorial_working_with_transactions` - in the
    :ref:`unified_tutorial`

    :meth:`_engine.Connection.begin_nested` - use a SAVEPOINT

    :meth:`_engine.Connection.begin_twophase` -
    use a two phase /XID transaction

    :meth:`_engine.Engine.begin` - context manager available from
    :class:`_engine.Engine`

zThis connection has already initialized a SQLAlchemy Transaction() object via begin() or autobegin; can't call begin() here unless rollback() or commit() is called first.)rQ   RootTransactionr   r   r   s    rg   r   Connection.begin  sB    @ $ / 5D$$$))# ry   c                R    U R                   c  U R                  5         [        U 5      $ )a?
  Begin a nested transaction (i.e. SAVEPOINT) and return a transaction
handle that controls the scope of the SAVEPOINT.

E.g.::

    with engine.begin() as connection:
        with connection.begin_nested():
            connection.execute(table.insert(), {"username": "sandy"})

The returned object is an instance of
:class:`_engine.NestedTransaction`, which includes transactional
methods :meth:`_engine.NestedTransaction.commit` and
:meth:`_engine.NestedTransaction.rollback`; for a nested transaction,
these methods correspond to the operations "RELEASE SAVEPOINT <name>"
and "ROLLBACK TO SAVEPOINT <name>". The name of the savepoint is local
to the :class:`_engine.NestedTransaction` object and is generated
automatically. Like any other :class:`_engine.Transaction`, the
:class:`_engine.NestedTransaction` may be used as a context manager as
illustrated above which will "release" or "rollback" corresponding to
if the operation within the block were successful or raised an
exception.

Nested transactions require SAVEPOINT support in the underlying
database, else the behavior is undefined. SAVEPOINT is commonly used to
run operations within a transaction that may fail, while continuing the
outer transaction. E.g.::

    from sqlalchemy import exc

    with engine.begin() as connection:
        trans = connection.begin_nested()
        try:
            connection.execute(table.insert(), {"username": "sandy"})
            trans.commit()
        except exc.IntegrityError:  # catch for duplicate username
            trans.rollback()  # rollback to savepoint

        # outer transaction continues
        connection.execute(...)

If :meth:`_engine.Connection.begin_nested` is called without first
calling :meth:`_engine.Connection.begin` or
:meth:`_engine.Engine.begin`, the :class:`_engine.Connection` object
will "autobegin" the outer transaction first. This outer transaction
may be committed using "commit-as-you-go" style, e.g.::

    with engine.connect() as connection:  # begin() wasn't called

        with connection.begin_nested():  # will auto-"begin()" first
            connection.execute(...)
        # savepoint is released

        connection.execute(...)

        # explicitly commit outer transaction
        connection.commit()

        # can continue working with connection here

.. versionchanged:: 2.0

    :meth:`_engine.Connection.begin_nested` will now participate
    in the connection "autobegin" behavior that is new as of
    2.0 / "future" style connections in 1.4.

.. seealso::

    :meth:`_engine.Connection.begin`

    :ref:`session_begin_nested` - ORM support for SAVEPOINT

)rQ   r   NestedTransactionr   s    rg   begin_nestedConnection.begin_nestedd  s&    R $OO &&ry   c                    U R                   b  [        R                  " S5      eUc$  U R                  R                  R                  5       n[        X5      $ )a  Begin a two-phase or XA transaction and return a transaction
handle.

The returned object is an instance of :class:`.TwoPhaseTransaction`,
which in addition to the methods provided by
:class:`.Transaction`, also provides a
:meth:`~.TwoPhaseTransaction.prepare` method.

:param xid: the two phase transaction id.  If not supplied, a
  random id will be generated.

.. seealso::

    :meth:`_engine.Connection.begin`

    :meth:`_engine.Connection.begin_twophase`

zOCannot start a two phase transaction when a transaction is already in progress.)rQ   r   r   rU   rI   
create_xidTwoPhaseTransaction)rc   xids     rg   begin_twophaseConnection.begin_twophase  sR    ( ())*  ;++%%002C"4--ry   c                \    U R                   (       a  U R                   R                  5         gg)a  Commit the transaction that is currently in progress.

This method commits the current transaction if one has been started.
If no transaction was started, the method has no effect, assuming
the connection is in a non-invalidated state.

A transaction is begun on a :class:`_engine.Connection` automatically
whenever a statement is first executed, or when the
:meth:`_engine.Connection.begin` method is called.

.. note:: The :meth:`_engine.Connection.commit` method only acts upon
  the primary database transaction that is linked to the
  :class:`_engine.Connection` object.  It does not operate upon a
  SAVEPOINT that would have been invoked from the
  :meth:`_engine.Connection.begin_nested` method; for control of a
  SAVEPOINT, call :meth:`_engine.NestedTransaction.commit` on the
  :class:`_engine.NestedTransaction` that is returned by the
  :meth:`_engine.Connection.begin_nested` method itself.


N)rQ   commitr   s    rg   r   Connection.commit  s$    , $$& ry   c                \    U R                   (       a  U R                   R                  5         gg)a  Roll back the transaction that is currently in progress.

This method rolls back the current transaction if one has been started.
If no transaction was started, the method has no effect.  If a
transaction was started and the connection is in an invalidated state,
the transaction is cleared using this method.

A transaction is begun on a :class:`_engine.Connection` automatically
whenever a statement is first executed, or when the
:meth:`_engine.Connection.begin` method is called.

.. note:: The :meth:`_engine.Connection.rollback` method only acts
  upon the primary database transaction that is linked to the
  :class:`_engine.Connection` object.  It does not operate upon a
  SAVEPOINT that would have been invoked from the
  :meth:`_engine.Connection.begin_nested` method; for control of a
  SAVEPOINT, call :meth:`_engine.NestedTransaction.rollback` on the
  :class:`_engine.NestedTransaction` that is returned by the
  :meth:`_engine.Connection.begin_nested` method itself.


N)rQ   rollbackr   s    rg   r   Connection.rollback  s$    . &&( ry   c                L    U R                   R                  R                  U 5      $ r   )rU   rI   do_recover_twophaser   s    rg   recover_twophaseConnection.recover_twophase  s    {{""66t<<ry   c                L    U R                   R                  R                  XUS9  g N)recover)rU   rI   do_rollback_twophaserc   r   r   s      rg   rollback_preparedConnection.rollback_prepared  s    00G0Lry   c                L    U R                   R                  R                  XUS9  g r   )rU   rI   do_commit_twophaser   s      rg   commit_preparedConnection.commit_prepared  s    ..t'.Jry   c                X    U R                   SL=(       a    U R                   R                  $ z,Return True if a transaction is in progress.N)rQ   	is_activer   s    rg   in_transactionConnection.in_transaction  s$      ,L1B1B1L1LLry   c                X    U R                   SL=(       a    U R                   R                  $ r  )rS   r  r   s    rg   in_nested_transaction Connection.in_nested_transaction  s+     $$D0 3((22	
ry   c                    U R                   R                  SS 5      n[        US:H  =(       d.    US L =(       a#    U R                  R                  R
                  S:H  5      $ )Nr   
AUTOCOMMIT)rO   r   boolrU   rI   _on_connect_isolation_level)rc   opt_isos     rg   _is_autocommit_isolation#Connection._is_autocommit_isolation  s\    ))--.?F|# 4  KK''CC 	
 	
ry   c                P    U R                   nUc  [        R                  " S5      eU$ )Nz"connection is not in a transaction)rQ   r   r   rc   transs     rg   _get_required_transaction$Connection._get_required_transaction!  s)    !!=))*NOOry   c                P    U R                   nUc  [        R                  " S5      eU$ )Nz)connection is not in a nested transaction)rS   r   r   r  s     rg    _get_required_nested_transaction+Connection._get_required_nested_transaction'  s/    ((=));  ry   c                    U R                   $ )zQReturn the current root transaction in progress, if any.

.. versionadded:: 1.4

)rQ   r   s    rg   get_transactionConnection.get_transaction/  s        ry   c                    U R                   $ )zSReturn the current nested transaction in progress, if any.

.. versionadded:: 1.4

)rS   r   s    rg   get_nested_transaction!Connection.get_nested_transaction8  s     '''ry   c                   U R                   (       a8  U R                  5       (       a  U R                  S5        OU R                  S5        SU l        U R                  (       d  U R
                  R                  (       a  U R                  R                  U 5         U R
                  R                  R                  U R                  5        SU l        g ! [         a  nU R                  US S S S 5         S nAN,S nAff = f! SU l        f = f)Nz?BEGIN (implicit; DBAPI should not BEGIN due to autocommit mode)zBEGIN (implicit)TF)r_   r  rw   r[   ra   rU   rK   r   rI   do_beginrd   r   r   rc   transactionr   s      rg   _begin_implConnection._begin_impl@  s    ::,,..'
 12t{{66MM%	$KK((9 $DO  	D((D$dCC	D $DOs*   /C 
C9C4/C< 4C99C< <	Dc                    U R                   (       d  U R                  R                   (       a  U R                  R                  U 5        U R                  (       az  U R
                  (       a8  U R                  5       (       a  U R                  S5        OU R                  S5         U R                  R                  R                  U R                  5        g g ! [         a  nU R                  US S S S 5         S nAg S nAff = f)NzVROLLBACK using DBAPI connection.rollback(), DBAPI should ignore due to autocommit modeROLLBACK)ra   rU   rK   r   r   r_   r  rw   rI   do_rollbackrd   r   r   r   s     rg   _rollback_implConnection._rollback_implV  s    t{{66MM""4(99zz0022NNE
 NN:.H##//@ : ! H,,QdD$GGHs   #/C 
C=C88C=c                   U R                   (       d  U R                  R                   (       a  U R                  R                  U 5        U R                  (       a8  U R                  5       (       a  U R                  S5        OU R                  S5         U R                  R                  R                  U R                  5        g ! [         a  nU R                  US S S S 5         S nAg S nAff = f)NzRCOMMIT using DBAPI connection.commit(), DBAPI should ignore due to autocommit modeCOMMIT)ra   rU   rK   r   r_   r  rw   rI   	do_commitrd   r   r   r   s     rg   _commit_implConnection._commit_implh  s    t{{66MM  &::,,..A
 x(	DKK))$//: 	D((D$dCC	Ds   /C 
C+C&&C+c                ,   U R                   (       d  U R                  R                   (       a  U R                  R                  X5        Uc$  U =R                  S-  sl        SU R                  -  nU R                  R
                  R                  X5        U$ )Nr   zsa_savepoint_%s)ra   rU   rK   	savepointrZ   rI   do_savepointrc   r   s     rg   _savepoint_implConnection._savepoint_imply  sl    t{{66MM##D/<  A% $t';';;D((4ry   c                   U R                   (       d  U R                  R                   (       a  U R                  R                  XS 5        U R                  (       a&  U R                  R
                  R                  X5        g g r   )ra   rU   rK   rollback_savepointr   rI   do_rollback_to_savepointr4  s     rg   _rollback_to_savepoint_impl&Connection._rollback_to_savepoint_impl  sQ    t{{66MM,,T>99KK88D :ry   c                    U R                   (       d  U R                  R                   (       a  U R                  R                  XS 5        U R                  R                  R                  X5        g r   )ra   rU   rK   release_savepointrI   do_release_savepointr4  s     rg   _release_savepoint_impl"Connection._release_savepoint_impl  sC    t{{66MM++D=00<ry   c                   U R                   (       a  U R                  S5        U R                  (       d  U R                  R                  (       a%  U R                  R                  XR                  5        SU l         U R                  R                  R                  XR                  5        SU l        g ! [         a  nU R                  US S S S 5         S nAN,S nAff = f! SU l        f = f)NzBEGIN TWOPHASE (implicit)TF)r_   rw   ra   rU   rK   r   r   r[   rI   do_begin_twophaser   r   r#  s      rg   _begin_twophase_implConnection._begin_twophase_impl  s    ::NN67t{{66MM((?	$KK11$H $DO  	D((D$dCC	D $DOs*   </B3 3
C=CC CC 	C(c                x   U R                   (       d  U R                  R                   (       a  U R                  R                  X5        [	        U R
                  [        5      (       d   e U R                  R                  R                  X5        g ! [         a  nU R                  US S S S 5         S nAg S nAff = fr   )ra   rU   rK   prepare_twophase
isinstancerQ   r   rI   do_prepare_twophaser   r   )rc   r   r   s      rg   _prepare_twophase_impl!Connection._prepare_twophase_impl  s    t{{66MM**45$++-@AAAA	DKK33D> 	D((D$dCC	Ds   *%B 
B9B44B9c                   U R                   (       d  U R                  R                   (       a  U R                  R                  XU5        U R                  (       aI  [        U R                  [        5      (       d   e U R                  R                  R                  XU5        g g ! [         a  nU R                  US S S S 5         S nAg S nAff = fr   )ra   rU   rK   rollback_twophaser   rG  rQ   r   rI   r   r   r   rc   r   is_preparedr   s       rg   _rollback_twophase_impl"Connection._rollback_twophase_impl  s    t{{66MM++D{C99d//1DEEEEH##88{ : ! H,,QdD$GGHs   <&B$ $
C.CCc                |   U R                   (       d  U R                  R                   (       a  U R                  R                  XU5        [	        U R
                  [        5      (       d   e U R                  R                  R                  XU5        g ! [         a  nU R                  US S S S 5         S nAg S nAff = fr   )ra   rU   rK   commit_twophaserG  rQ   r   rI   r  r   r   rM  s       rg   _commit_twophase_impl Connection._commit_twophase_impl  s    t{{66MM))$[A$++-@AAAA	DKK224kJ 	D((D$dCC	Ds   +&B 
B;B66B;c                   U R                   (       a  U R                   R                  5         SnOSnU R                  bD  U R                  nU(       a  [        SU5      R	                  SS9  OUR                  5         SU l        SU l        g)a_  Close this :class:`_engine.Connection`.

This results in a release of the underlying database
resources, that is, the DBAPI connection referenced
internally. The DBAPI connection is typically restored
back to the connection-holding :class:`_pool.Pool` referenced
by the :class:`_engine.Engine` that produced this
:class:`_engine.Connection`. Any transactional state present on
the DBAPI connection is also unconditionally released via
the DBAPI connection's ``rollback()`` method, regardless
of any :class:`.Transaction` object that may be
outstanding with regards to this :class:`_engine.Connection`.

This has the effect of also calling :meth:`_engine.Connection.rollback`
if any transaction is in place.

After :meth:`_engine.Connection.close` is called, the
:class:`_engine.Connection` is permanently in a closed state,
and will allow no further operations.

TFNr5   )transaction_reset)rQ   r   rN   r   _close_specialr\   )rc   
skip_resetconns      rg   r   Connection.close  s    . ##%JJ!!-))D '.==&* >  

 &*D"$ry   r   c                   g r   r   rc   	statement
parametersr   s       rg   scalarConnection.scalar  s     ry   c                   g r   r   r]  s       rg   r`  ra    s     ry   c                   [        U5      n UR                  nU" U UU=(       d    [        5      $ ! [         a  n[        R
                  " U5      UeSnAff = f)aE  Executes a SQL statement construct and returns a scalar object.

This method is shorthand for invoking the
:meth:`_engine.Result.scalar` method after invoking the
:meth:`_engine.Connection.execute` method.  Parameters are equivalent.

:return: a scalar Python value representing the first column of the
 first row returned.

N)r   _execute_on_scalarrE   AttributeErrorr   ObjectNotExecutableErrorrc   r^  r_  r   distilled_parametersmethrf   s          rg   r`  ra    sc    "  2*=		//D $!/Z   	C..y9sB	C   0 
AAAc                   g r   r   r]  s       rg   scalarsConnection.scalars       ry   c                   g r   r   r]  s       rg   rl  rm  '        ry   c               >    U R                  XUS9R                  5       $ )a  Executes and returns a scalar result set, which yields scalar values
from the first column of each row.

This method is equivalent to calling :meth:`_engine.Connection.execute`
to receive a :class:`_result.Result` object, then invoking the
:meth:`_result.Result.scalars` method to produce a
:class:`_result.ScalarResult` instance.

:return: a :class:`_result.ScalarResult`

.. versionadded:: 1.4.24

r[  )executerl  r]  s       rg   rl  rm  0  s'    * ||5F  

')	ry   c                   g r   r   r]  s       rg   rr  Connection.executeI  rn  ry   c                   g r   r   r]  s       rg   rr  rt  R  rp  ry   c                   [        U5      n UR                  nU" U UU=(       d    [        5      $ ! [         a  n[        R
                  " U5      UeSnAff = f)a  Executes a SQL statement construct and returns a
:class:`_engine.CursorResult`.

:param statement: The statement to be executed.  This is always
 an object that is in both the :class:`_expression.ClauseElement` and
 :class:`_expression.Executable` hierarchies, including:

 * :class:`_expression.Select`
 * :class:`_expression.Insert`, :class:`_expression.Update`,
   :class:`_expression.Delete`
 * :class:`_expression.TextClause` and
   :class:`_expression.TextualSelect`
 * :class:`_schema.DDL` and objects which inherit from
   :class:`_schema.ExecutableDDLElement`

:param parameters: parameters which will be bound into the statement.
 This may be either a dictionary of parameter names to values,
 or a mutable sequence (e.g. a list) of dictionaries.  When a
 list of dictionaries is passed, the underlying statement execution
 will make use of the DBAPI ``cursor.executemany()`` method.
 When a single dictionary is passed, the DBAPI ``cursor.execute()``
 method will be used.

:param execution_options: optional dictionary of execution options,
 which will be associated with the statement execution.  This
 dictionary can provide a subset of the options that are accepted
 by :meth:`_engine.Connection.execution_options`.

:return: a :class:`_engine.Result` object.

N)r   _execute_on_connectionrE   re  r   rf  rg  s          rg   rr  rt  [  sd    L  2*=		33D $!/Z   	C..y9sB	Crj  c                B    U R                  UR                  5       X#5      $ )z%Execute a sql.FunctionElement object.)_execute_clauseelementselect)rc   funcrh  r   s       rg   _execute_functionConnection._execute_function  s#     **KKM/
 	
ry   c                   U R                   R                  U5      nU R                  (       d  U R                  R                  (       a  U R	                  XU5      u  nnnnOS=pE U R
                  nUc  U R                  5       nU R                  nUR                  R                  XpXc5      nWR                  SUS5      n
U R                  (       d  U R                  R                  (       a   U R                   R#                  U UUUUU
5        U
$ ! [        R                  [        R                  4 a    e [         a  n	U R                  U	SSSS5         Sn	A	NSn	A	ff = f)z&Execute a schema.ColumnDefault object.N)rO   
merge_withra   rU   _invoke_before_exec_eventrN   r   rI   execution_ctx_cls_init_defaultr   r   r   r   r   _exec_defaultrK   after_execute)rc   defaultrh  r   event_multiparamsevent_paramsrY  rI   ctxr   rets              rg   _execute_defaultConnection._execute_default  sN    !33>>
 t{{66 ../@$!
 043	D))D|224llG++99tC gt4t{{66MM''!! 
# ((#*A*AB 	 	D((D$dCC	Ds   $AD .E:EEc                &   UR                   R                  U R                   U5      nU R                  (       d  U R                  R                  (       a  U R	                  XU5      u  nnnnOS=pVUR                  SS5      nU R                  nUR                  XS9n	U R                  UUR                  R                  U	SUU	5      n
U R                  (       d  U R                  R                  (       a   U R                  R                  U UUUUU
5        U
$ )zExecute a schema.DDL object.Nr   )rI   r   )rO   r  ra   rU   r  r   rI   compile_execute_contextr  	_init_ddlrK   r  )rc   ddlrh  r   	exec_optsr  r  r   rI   compiledr  s              rg   _execute_ddlConnection._execute_ddl  s    **55##%6
	 t{{66 ..9$!
 043(}}-CTJ,,;;  
 ##%%//
 t{{66MM''! 
ry   c                   [        U5      S:X  a  / US   pTOU0 pTU R                  R                   H  nU" U UUUU5      u  pnM     U(       a)  [        U5      nU(       a  [        R
                  " S5      eOU(       a  U/nO/ nXXE4$ )Nr   r   zLEvent handler can't return non-empty multiparams and params at the same time)lenrK   before_executelistr   r   )rc   elemdistilled_paramsr   r  r  fns          rg   r  $Connection._invoke_before_exec_event	  s      A%.02B12E|.>|--..B46!!51D\ / #$56--2  
  ,~!'8FFry   c                   UR                   R                  U R                   U5      nU R                  =(       d    U R                  R                  nU(       a  U R	                  XU5      u  nnnnU(       a  [        US   5      n[        U5      S:  nO/ nSnU R                  n	UR                  SS5      n
UR                  SU R                  R                  5      nUR                  U	UUUU
U R                  R                  [        R                  -  S9u  pnU R                  U	U	R                  R                   UUUUUUUUS9
nU(       a   U R"                  R%                  U UWWUU5        U$ )	z#Execute a sql.ClauseElement object.r   r   Fr   Nr   )rI   r   column_keysfor_executemanyr   linting)	cache_hit)rO   r  ra   rU   r  sortedr  rI   r   _compiled_cache_compile_w_cachecompiler_lintingr"   WARN_LINTINGr  r  _init_compiledrK   r  )rc   r  rh  r   
has_eventsr  r  keysr  rI   r   r   compiled_sqlextracted_paramsr  r  s                   rg   ry  !Connection._execute_clauseelement3  s    !33>>##%6
 %%@)@)@
 ..,=$!
   .q12D!"67!;OD#O,,044"D 
 7H6K6Kdkk997
 594I4I)+!5LL11H4I4II 5J 5
1	 ##%%44   $ 
 MM''!! 
ry   c                   UR                   R                  U R                  U5      nU R                  (       d  U R                  R                  (       a  U R                  XU5      u  nnnnU R                  nU R                  UUR                  R                  UUUUUSS5	      nU R                  (       d  U R                  R                  (       a   U R                  R                  U UWWUU5        U$ )zYExecute a sql.Compiled object.

TODO: why do we have this?   likely deprecate or remove

N)r   r  rO   ra   rU   r  rI   r  r  r  rK   r  )rc   r  rh  r   r  r  rI   r  s           rg   _execute_compiledConnection._execute_compiled|  s     %66AA##%6
 t{{66 ..0A$!
 ,,##%%44  

 t{{66MM''!! 
ry   c           	         [        U5      nU R                  R                  U5      nU R                  nU R	                  UUR
                  R                  USUUU5      nU$ )a4  Executes a string SQL statement on the DBAPI cursor directly,
without any SQL compilation steps.

This can be used to pass any string directly to the
``cursor.execute()`` method of the DBAPI in use.

:param statement: The statement str to be executed.   Bound parameters
 must use the underlying DBAPI's paramstyle, such as "qmark",
 "pyformat", "format", etc.

:param parameters: represent bound parameter values to be used in the
 execution.  The format is one of:   a dictionary of named parameters,
 a tuple of positional parameters, or a list containing either
 dictionaries or tuples for multiple-execute support.

:return: a :class:`_engine.CursorResult`.

 E.g. multiple dictionaries::


     conn.exec_driver_sql(
         "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)",
         [{"id": 1, "value": "v1"}, {"id": 2, "value": "v2"}],
     )

 Single dictionary::

     conn.exec_driver_sql(
         "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)",
         dict(id=1, value="v1"),
     )

 Single tuple::

     conn.exec_driver_sql(
         "INSERT INTO table (id, value) VALUES (?, ?)", (1, "v1")
     )

 .. note:: The :meth:`_engine.Connection.exec_driver_sql` method does
     not participate in the
     :meth:`_events.ConnectionEvents.before_execute` and
     :meth:`_events.ConnectionEvents.after_execute` events.   To
     intercept calls to :meth:`_engine.Connection.exec_driver_sql`, use
     :meth:`_events.ConnectionEvents.before_cursor_execute` and
     :meth:`_events.ConnectionEvents.after_cursor_execute`.

 .. seealso::

    :pep:`249`

N)r   rO   r  rI   r  r  _init_statement)rc   r^  r_  r   rh  rI   r  s          rg   exec_driver_sqlConnection.exec_driver_sql  sm    t  3:> 33>>
 ,,##%%55 
 
ry   c                r   U(       a-  UR                  SS5      nU(       a  UR                  SUS.5      n U R                  n	U	c  U R                  5       n	U" XX/UQ70 UD6n
U R                  (       a  U R                  R                  (       a,  U R                  (       a,  U R                  R                  (       d  U R                  5         O'U R                  (       a  [        R                   " U 5        U R                  c  U R#                  5         W
R%                  5         U
R&                  [(        R*                  L a  U R-                  X5      $ U R/                  XX45      $ ! [        R
                  [        R                  4 a    e [         a)  nU R                  U[        U5      USS5         SnAGNOSnAff = f)z\Create an :class:`.ExecutionContext` and execute, returning
a :class:`_engine.CursorResult`.r   NT)r   r   )r   r   rN   r   r   r   r   r   r   strrQ   r  rS   r   rL   r   _trans_ctx_checkr   pre_execexecute_styler   INSERTMANYVALUES_exec_insertmany_context_exec_single_context)rc   rI   constructorr^  r_  r   argsru   yprY  contextr   s               rg   r  Connection._execute_context  s}    "&&{D9B$5$;$;'+rB%!	))D|224!t9=ACG %%//((00:: %%'(( 11$7$OO  L$A$AA00BB,,) 9 ((#*A*AB 	 	((3y>:tT 	s   ,E .F6F11F6c           
     0   UR                   [        R                  L a4  UR                  5       nU(       a   UR	                  UR
                  XR5        UR
                  UR                  UR                  pHnUR                  (       d  US   n	OUn	U R                  (       d  U R                  R                  (       a6  U R                  R                   H  n
U
" U UUU	UUR                  5      u  pM     U R                   (       a  U R#                  U5        UR%                  5       nU R                  R&                  (       d2  U R#                  SU[(        R*                  " U	SUR                  S95        OU R#                  SU5        Sn UR,                  [.        R0                  L a  [3        SU	5      n	U R4                  R                  (       a;  U R4                  R                  R6                   H  n
U
" UUU	U5      (       d  M  S	n  O   U(       d  U R4                  R7                  UUU	U5        GOU	(       d  UR8                  (       ax  U R4                  R                  (       a9  U R4                  R                  R:                   H  n
U
" XxU5      (       d  M  S	n  O   U(       d  U R4                  R;                  XxU5        O[3        S
U	5      n	U R4                  R                  (       a;  U R4                  R                  R<                   H  n
U
" UUU	U5      (       d  M  S	n  O   U(       d  U R4                  R=                  XxX5        U R                  (       d  U R                  R                  (       a*  U R                  R?                  U UUU	UUR                  5        URA                  5         URC                  5       nU$ ! [         a)  nU R                  U[        U5      USU5         SnAGNSnAff = f! [         a  nU R                  XhXU5         SnAW$ SnAff = f)zjcontinue the _execute_context() method for a single DBAPI
cursor.execute() or cursor.executemany() call.

Nr   [%s] %r
   batchesismulti8[%s] [SQL parameters hidden due to hide_parameters=True]Fr(   Tr)   )"bind_typingr   SETINPUTSIZES_prepare_set_input_sizesdo_set_input_sizescursorr   r   r  r^  r_  executemanyra   rU   rK   before_cursor_executer_   rw   _get_cache_statshide_parameterssql_util_repr_paramsr  r   EXECUTEMANYr   rI   do_executemanyr   do_execute_no_params
do_executeafter_cursor_execute	post_exec_setup_result_proxy)rc   rI   r  r^  r_  generic_setinputsizesr   r  str_statementeffective_parametersr  statsevt_handledresults                 rg   r  Connection._exec_single_context6  s    *":"::$+$D$D$F!$..(= NN  * ""#-a= #- t{{66mm9968!(''733 : ::NN=),,.E;;..)), " ' 3 3 N
 "D	$$(@(@@'+-/C($ <<++"ll33BB")0#	  +/K! C #LL//%,	 *g.C.C<<++"ll33HHfW==*.K! I #LL55w (,.0D($ <<++"ll33>>")0#	  +/K! ? #LL++/C 4;;#:#:22!('' 002F s % 003y>:tW h  	(("6  	sE   N7 A5O- =BO- BO- BO- 7
O*O%%O*-
P7PPc                   UR                   [        R                  L a  UR                  5       nOSnUR                  UR
                  UR                  penUnU R                  =(       d    U R                  R                  nU R                  R                  (       a!  U R                  R                  R                  n	OSn	U R                  (       a  UR                  5       S-   n
UR                  R                  SS5      nSnUR!                  U UUUUU5       GH  nUR"                  (       a(   UR%                  UR                  UR"                  U5        UR.                  nUR0                  nU(       a-  U R                  R2                   H  nU" U UUUUS5      u  nnM     U R                  (       a  U R5                  [*        R,                  " U5      5        S	UR6                   S
UR8                   SUR:                  (       a  SOS UR<                  (       a  SOS S3nUR6                  S:X  a  W
U-  n
OSU 3n
U R                  R>                  (       d(  U R5                  SU
[*        R@                  " USSS95        OU R5                  SU
5         U	 H  nU" UUUU5      (       d  M    O   UR                  UUUU5         U(       a*  U R                  RC                  U UUUUURD                  5        U(       d  GM  XRF                  -  nGM      URI                  5         U(       a  Xl%        URM                  5       nU$ ! [&         aG  nU R)                  U[*        R,                  " UR.                  5      UR0                  SUSS9   SnAGN5SnAff = f! [&         a3  nU R)                  U[*        R,                  " U5      UUUSS9   SnAGN
SnAff = f! [&         a  nU R)                  XXtU5         SnAW$ SnAff = f)zcontinue the _execute_context() method for an "insertmanyvalues"
operation, which will invoke DBAPI
cursor.execute() one or more times with individual log and
event hook calls.

Nr   z (insertmanyvalues)r   Fr   T)is_sub_exec /z (ordered	unorderedz; batch not supportedr   )r   insertmanyvaluesr  r  r  r  )'r  r   r  r  r  r^  r_  ra   rU   rI   rK   r  r_   r  r   r   !_deliver_insertmanyvalues_batchesprocessed_setinputsizesr  r   r   r  _long_statementreplaced_statementreplaced_parametersr  rw   batchnumtotal_batchesrows_sortedis_downgradedr  r  r  r  current_batch_sizer  	_rowcountr  )rc   rI   r  r  r  r  r_  r  engine_eventsdo_execute_dispatchr  r   rowcount	imv_batchr   sub_stmt
sub_paramsr  	imv_statsr  s                       rg   r  #Connection._exec_insertmany_context  s    *":"::$+$D$D$F!$(! NN  *  *((CDKK,C,C<<##%%00   #%::,,.1FFE#5599
  BB !
I 00..!99 !33H"66J--==B+- ",(Hj > zzx77AB !)"4"4!5Q%337 ,, 2=
 !.. , 		 %%*Y&E.yk:E{{22NN! --&$&$) NN0-B "	   . && "	" 22!('' ! 888c
f	 $,!002F c % 00 001M1MN!55$( 1 Z ! ,,,,X6 $ - >  	(("6  	sT   +'L;N$N&N-O ;
N<NN
O(OO
O7O22O7c           	        U R                   (       d  U R                  R                   (       a*  U R                  R                   H  nU" XX#US5      u  p#M     U R                  (       a#  U R                  U5        U R                  SU5         U R                  R                   (       d  SOU R                  R                  R                   H  nU" XX45      (       d  M    O   U R                  R                  XX45         U R                   (       d  U R                  R                   (       a  U R                  R                  XX#US5        gg! [         a  nU R                  XbX1U5         SnANnSnAff = f)a/  Execute a statement + params on the given cursor.

Adds appropriate logging and exception handling.

This method is used by DefaultDialect for special-case
executions, such as for sequences and column defaults.
The path of statement execution in the majority of cases
terminates at _execute_context().

Fz[raw sql] %rr   N)ra   rU   rK   r  r_   rw   rI   r  r   r   r  )rc   r  r^  r_  r  r  r   s          rg   _cursor_executeConnection._cursor_executeo  s.   " t{{66mm99(*)%)%	: :
 ::NN9%NN>:6	 ||// \\**556 
 f==6 '':O t{{66MM..iWe  7  	((j' 	s%   AE	 E	 E	 	
E0E++E0c                     UR                  5         g! [         a1    U R                  R                  R                  R                  SSS9   gf = f)zLClose the given cursor, catching exceptions
and turning into log warnings.

zError closing cursorT)exc_infoN)r   	ExceptionrU   poolrp   error)rc   r  s     rg   _safe_close_cursorConnection._safe_close_cursor  sG    
	LLN 	KK##))& * 	s    8AAc                	   [         R                  " 5       n[        R                  " U5      nU R                  (       d  [        XR                  R                  R                  5      =(       aR    U R                  (       + =(       a:    U R                  R                  UU R                  (       d  U R                  OS U5      =(       d    U=(       a    U R                  (       + U l        U(       + n	Ub  U(       + =(       a    UR                  OSn
U R                  (       ar  [        R                   R#                  UUUU R                  R                  R                  U R$                  R&                  U R                  U
S9R)                  US   5      UeSU l         [        XR                  R                  R                  5      =(       d    US L=(       a    US L =(       a    U(       + nU(       ay  [        R                   R#                  UU[+        [,        U5      U R                  R                  R                  U R$                  R&                  U R                  U R                  U
S9nOS nS nU R                  R.                  (       a  U R0                  R3                  SS5      (       d  [5        UUU R$                  U R                  U UUUUU R                  U	S5      nU R                  R6                  R8                   H  n U" U5      nUb  U=Ul        nM  M     U R                  UR                  :w  a)  UR                  U l        U(       a  UR                  Ul        UR>                  n	U(       a  U(       a  URA                  U5        U R                  (       d=  U(       a  U RC                  U5        U RE                  5       (       d  U RG                  5         U(       a  UR)                  US   5      UeU(       a  Uc   eUR)                  US   5      UeUS   c   eUS   R)                  US   5      e! [,         a  nUn S nA  GM,  S nAff = f! U ?U R                  (       ad  U ?U R                  (       dP  U R                  nUc   eU	(       a&  U R$                  RH                  RK                  UU5        U RM                  U5        f f f = f)NF)r  rI   r  r   T)r  connection_invalidatedrI   r  skip_user_error_eventsr   )'sysr   r!   is_exit_exception_is_disconnectrG  rI   rW   rX   r   is_disconnectr   rN   r  _reentrant_errorr   
DBAPIErrorinstancerU   r  with_tracebackr   r  ra   rO   r   ExceptionContextImplrK   handle_errorchained_exceptionr  invalidate_pool_on_disconnecthandle_dbapi_exceptionr  r  r*  r  _invalidater   )rc   r   r^  r_  r  r  r  r   r
  r  r  should_wrapsqlalchemy_exceptionnewraiser  r  per_fn_raiseddbapi_conn_wrappers                      rg   r   "Connection._handle_dbapi_exception  s*    <<> 2215""1ll77==> OLL..262B2BD**#9 $7DKK  ->(=% " O3 3 3 	
   ..))))// $ ; ; *  nXa[)q1 !%e	' %Q(A(A(G(GH % *tO*))  '*~~'>'>A&LL--33$(KK$?$?+/+>+> LL# (? 	($ (,$H(($2I2I2M2M(%3 3 +(KKLL''1 ,,//<<B	 "$C!-?EEC1H . = &&#*;*;;*-*;*;D'+-- -C 55 . w..q1&&++F3 **,,'')--hqk:A+777*99(1+FAM{...qk00!==S % #*V %""''')-)?)?&-9994((445GKOOA& ( #s9   E$Q	 ;P-DQ	 -
Q7Q9Q	 QQ	 	A9Sc                   [         R                  " 5       nUc9  [        XR                  R                  5      =(       a    UR                  US S 5      n[        XR                  R                  5      nU(       aU  [        R                  R                  S S [        [        U5      UR                  R                  Ub  UR                  OSUUS9n	OS n	S n
UR                  (       aq  [        UU	UUS S S S S UUU5      nUR                  R                   H  n U" U5      nUb  U=Ul        n
M  M     U	(       a   XKR
                  :w  a  UR
                  U	l        U
(       a  U
R%                  US   5      UeU(       a  U	c   eU	R%                  US   5      UeUS   c   eUS   R%                  US   5      e! [         a  nUn
 S nA  M  S nAff = f)NF)r  r  rI   r   r   )r	  r   rG  rW   rX   r  r   r  r  r   r  r  ra   r  rK   r  r  r  r  )clsr   rI   rU   r  r  is_pre_pingr   r  r  r  r  r  r  r  s                  rg   rY   /Connection._handle_dbapi_exception_noconnection>	  s    <<> &''-- 7''46  !$8$8$>$>?#&>>#:#:Y"$$**.4.@F**e'4 $; 
$  $( &$-C &&33	  WF);AA- * 4 $9J9J(J>A>O>O$;))(1+6A='333&55hqkBIA;***1+,,Xa[99 ! &Hs   F//
G9GGc                L    U" SU R                   U S.UD6R                  U5        g)zrun a DDL visitor.

This method is only here so that the MockConnection can change the
options given to the visitor so that "checkfirst" is skipped.

)rI   rd   Nr   )rI   traverse_single)rc   visitorcallableelementkwargss       rg   _run_ddl_visitorConnection._run_ddl_visitor	  s,     	 	
LLT	
5;	

/'
"ry   )__can_reconnect
__in_begin__savepoint_seqr]   rN   r_   rO   ra   r  rS   r  rQ   rI   rK   rU   )NNTT)
rU   Enginerd   rM   ra   Optional[bool]re   r  r]   r  )rs   r  rt   r   ru   r   returnNone)r.   Optional[SchemaTranslateMapType])r   r?   r.  Optional[str]r.  rG   )r   r   r   r   r   r   r.  r/  )r   Optional[CompiledCacheType]r   r  r   r   r   r  r   r  r   intr   r4  r   r4  r   r0  r   r  r   r   r.  rG   )r   r   r.  rG   r.  r,   r.  r  r.  r7   )r.  r   )r.  zOptional[IsolationLevel])r.  r   )r.  r9   r   )r   zOptional[BaseException]r.  r/  r.  r/  )r.  r   )r.  r   )r   zOptional[Any]r.  r   )r.  z	List[Any]F)r   r   r   r  r.  r/  )r.  rP   )r.  rR   )r$  r   r.  r/  )r   r1  r.  r  )r   r  r.  r/  )r$  r   r.  r/  )r   r   r.  r/  )r   r   rN  r  r.  r/  )r^  TypedReturnsRows[Tuple[_T]]r_  "Optional[_CoreSingleExecuteParams]r   %Optional[CoreExecuteOptionsParameter]r.  zOptional[_T])r^  r8   r_  r;  r   r<  r.  r   )r^  r:  r_  Optional[_CoreAnyExecuteParams]r   r<  r.  zScalarResult[_T])r^  r8   r_  r=  r   r<  r.  zScalarResult[Any])r^  zTypedReturnsRows[_T]r_  r=  r   r<  r.  zCursorResult[_T])r^  r8   r_  r=  r   r<  r.  CursorResult[Any])r{  zFunctionElement[Any]rh  r(   r   r.   r.  r>  )r  r>   rh  r(   r   r.   r.  r   )r  r;   rh  r(   r   r.   r.  r>  )r  r   r  r(   r   r,   r.  zVTuple[Any, _CoreMultiExecuteParams, _CoreMultiExecuteParams, _CoreSingleExecuteParams])r  r8   rh  r(   r   r.   r.  r>  )r  r:   rh  r(   r   r.   r.  r>  )NN)r^  r  r_   Optional[_DBAPIAnyExecuteParams]r   r<  r.  r>  )rI   r/   r  zCallable[..., ExecutionContext]r^  Union[str, Compiled]r_   Optional[_AnyMultiExecuteParams]r   r,   r  r   ru   r   r.  r>  )
rI   r/   r  r   r^  r@  r_  rA  r.  r>  )rI   r/   r  r   r.  r>  )
r  r   r^  r  r_  r+   r  Optional[ExecutionContext]r.  r/  )r  r   r.  r/  )r   r   r^  r1  r_  zOptional[_AnyExecuteParams]r  Optional[DBAPICursor]r  rB  r  r  r.  r   )NNTF)r   r   rI   r/   rU   Optional[Engine]r  r-  r  r  r   r  r.  r   r$  zType[InvokeDDLBase]r%  r@   r&  r   r.  r/  )R__name__
__module____qualname____firstlineno____doc____annotations___sqla_logger_namespacerL   should_close_with_resultrh   rj   rw   r|   propertyr   r   r   r   r   r   r   r   r   r   rd   r   r   r   r   rq   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r  r%  r*  r/  r5  r:  r?  rC  rI  rO  rS  r   r`  rl  rr  r|  r  r  r  ry  rD   r  r  r  r  r  r  r  r  r  r   classmethodrY   r'  __static_attributes__r   ry   rg   rG   rG   V   s   0 00; >B:A
  %66''++44
 7;&*"&!%+/+/ 4+/ $	+/
  +/ +/^ #"	5	6 $ $(  7: *-#$!*-AD"' 4 	
 (     %( ?    
   > >EN	' 
 
 K K
 H H( * *2*DX 4 48
C $ $9&v")HIVL'\.:'2)4=MKM
	
!($,H$D"E=$DHD.%`  :>
 DH. 7
 A 
   :>
 DH 7
 A 
  :>
 DH 7
 A 
:  7;
 DH. 4
 A 
   7; 
 DH   4 
 A  
    7;
 DH 4
 A 
2  7;
 DH' 4
 A 
   7; 
 DH   4 
 A  
    7;0
 DH00 40
 A0 
0d

"

 6

 7	


 


9!9 69 7	9
 
9v3!3 63 7	3
 
3j(G(G 2(G +	(G

(GTGG 6G 7	G
 
GZ :O	00 60 7	0
 
0j 8<CG	KK 5K A	K
 
KZ99 59 (	9
 59 +9 9 9 
9vLL "L (	L
 5L 
L\ii "i 
	i` /3,, , .	,
 ,, 
,\ N "O'O' !O' 0	O'
 &O' ,O' O' 
O'b 
 $((,.2!H:H: H: !	H:
 &H: (,H: H: 
H: H:T#,# !# 	#
 
#ry   rG   r1   c                  V    \ rS rSrSrSr                        SS jrSrg)r  i	  z3Implement the :class:`.ExceptionContext` interface.)rd   rU   rI   r  r^  r_  original_exceptionr  r  execution_contextr  r  r   c                    X0l         X@l        XPl        X l        Xl        Xl        Xpl        Xl        Xl        Xl	        Xl
        g r   )rU   rI   rd   r  rR  rS  r^  r_  r  r  r   )rc   r   r  rU   rI   rd   r  r^  r_  r  r  r  r   s                rg   rh   ExceptionContextImpl.__init__	  sA     $$8!"+!("$*-J*&ry   )rd   rI   rU   rS  r  r  r   rR  r_  r  r^  N)r   r   r  zOptional[exc.StatementError]rU   rD  rI   r/   rd   Optional[Connection]r  rC  r^  r1  r_  r?  r  rB  r  r  r  r  r   r  )rF  rG  rH  rI  rJ  	__slots__rh   rP  r   ry   rg   r  r  	  s    =I ' ' ;' !	'
 ' )' &' !' 5' ,' ' (,' 'ry   r  c                      \ rS rSr% SrSrSrS\S'   S\S'   S\S	'   SS
 jr\	SS j5       r
SS jrSS jrSS jr\	SS j5       rSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)Transactioni	  a  Represent a database transaction in progress.

The :class:`.Transaction` object is procured by
calling the :meth:`_engine.Connection.begin` method of
:class:`_engine.Connection`::

    from sqlalchemy import create_engine

    engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test")
    connection = engine.connect()
    trans = connection.begin()
    connection.execute(text("insert into x (a, b) values (1, 2)"))
    trans.commit()

The object provides :meth:`.rollback` and :meth:`.commit`
methods in order to control transaction boundaries.  It
also implements a context manager interface so that
the Python ``with`` statement can be used with the
:meth:`_engine.Connection.begin` method::

    with connection.begin():
        connection.execute(text("insert into x (a, b) values (1, 2)"))

The Transaction object is **not** threadsafe.

.. seealso::

    :meth:`_engine.Connection.begin`

    :meth:`_engine.Connection.begin_twophase`

    :meth:`_engine.Connection.begin_nested`

.. index::
  single: thread safety; Transaction
r   Fr  _is_rootr  rG   rd   c                    [        5       er   NotImplementedErrorrc   rd   s     rg   rh   Transaction.__init__	      !##ry   c                    [        5       e)zsTrue if this transaction is totally deactivated from the connection
and therefore can no longer affect its state.

r\  r   s    rg   _deactivated_from_connection(Transaction._deactivated_from_connection	  s     "##ry   c                    [        5       er   r\  r   s    rg   	_do_closeTransaction._do_close 
  r`  ry   c                    [        5       er   r\  r   s    rg   _do_rollbackTransaction._do_rollback
  r`  ry   c                    [        5       er   r\  r   s    rg   
_do_commitTransaction._do_commit
  r`  ry   c                ^    U R                   =(       a    U R                  R                  (       + $ r   )r  rd   r   r   s    rg   r   Transaction.is_valid	
  s    ~~Adoo&A&A"AAry   c                |     U R                  5         U R                  (       a   eg! U R                  (       a   ef = f)a  Close this :class:`.Transaction`.

If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback().  Otherwise, the
method returns.

This is used to cancel a Transaction without affecting the scope of
an enclosing transaction.

N)re  r  r   s    rg   r   Transaction.close
  s0    	&NN~~%%~t~~%%~   & ;c                |     U R                  5         U R                  (       a   eg! U R                  (       a   ef = f)a  Roll back this :class:`.Transaction`.

The implementation of this may vary based on the type of transaction in
use:

* For a simple database transaction (e.g. :class:`.RootTransaction`),
  it corresponds to a ROLLBACK.

* For a :class:`.NestedTransaction`, it corresponds to a
  "ROLLBACK TO SAVEPOINT" operation.

* For a :class:`.TwoPhaseTransaction`, DBAPI-specific methods for two
  phase transactions may be used.


N)rh  r  r   s    rg   r   Transaction.rollback
  s2    "	&~~%%~t~~%%~rq  c                |     U R                  5         U R                  (       a   eg! U R                  (       a   ef = f)a  Commit this :class:`.Transaction`.

The implementation of this may vary based on the type of transaction in
use:

* For a simple database transaction (e.g. :class:`.RootTransaction`),
  it corresponds to a COMMIT.

* For a :class:`.NestedTransaction`, it corresponds to a
  "RELEASE SAVEPOINT" operation.

* For a :class:`.TwoPhaseTransaction`, DBAPI-specific methods for two
  phase transactions may be used.

N)rk  r  r   s    rg   r   Transaction.commit3
  s0     	&OO~~%%~t~~%%~rq  c                    U R                   $ r   )rd   r   s    rg   _get_subjectTransaction._get_subjectH
  s    ry   c                    U R                   $ r   )r  r   s    rg   _transaction_is_active"Transaction._transaction_is_activeK
  s    ~~ry   c                $    U R                   (       + $ r   )rb  r   s    rg   _transaction_is_closed"Transaction._transaction_is_closedN
  s    4444ry   c                    gNTr   r   s    rg   _rollback_can_be_called#Transaction._rollback_can_be_calledQ
  s    
 ry   Nrd   rG   r6  r8  r2  )rF  rG  rH  rI  rJ  rW  rZ  rK  rh   rN  rb  re  rh  rk  r   r   r   r   rw  rz  r}  r  rP  r   ry   rg   rY  rY  	  s    #J IHdO$ $ $$$$ B B& &,&*5ry   rY  c                      \ rS rSrSrSrSrSS jrSS jr\	SS j5       r
SS jrSS	 jrSS
 jrSSS jjrSS jrSS jrSS jrSrg)r   iY
  a  Represent the "root" transaction on a :class:`_engine.Connection`.

This corresponds to the current "BEGIN/COMMIT/ROLLBACK" that's occurring
for the :class:`_engine.Connection`. The :class:`_engine.RootTransaction`
is created by calling upon the :meth:`_engine.Connection.begin` method, and
remains associated with the :class:`_engine.Connection` throughout its
active span. The current :class:`_engine.RootTransaction` in use is
accessible via the :attr:`_engine.Connection.get_transaction` method of
:class:`_engine.Connection`.

In :term:`2.0 style` use, the :class:`_engine.Connection` also employs
"autobegin" behavior that will create a new
:class:`_engine.RootTransaction` whenever a connection in a
non-transactional state is used to emit commands on the DBAPI connection.
The scope of the :class:`_engine.RootTransaction` in 2.0 style
use can be controlled using the :meth:`_engine.Connection.commit` and
:meth:`_engine.Connection.rollback` methods.


T)rd   r  c                    UR                   b   eUR                  (       a  [        R                  " U5        Xl        U R                  5         Xl         SU l        g r  )rQ   rL   r   r  rd   _connection_begin_implr  r^  s     rg   rh   RootTransaction.__init__s
  sI    &&...,, 11*=$##%"&ry   c                    U R                   (       a#  U R                  R                  U L d   eSU l         g U R                  R                  U La  [        R                  " S5        g g )NFz0transaction already deassociated from connection)r  rd   rQ   r!   warnr   s    rg   _deactivate_from_connection+RootTransaction._deactivate_from_connection}
  sL    >>??//4777"DN__))5IIHI 6ry   c                2    U R                   R                  U L$ r   )rd   rQ   r   s    rg   rb  ,RootTransaction._deactivated_from_connection
  s    ++477ry   c                :    U R                   R                  U 5        g r   )rd   r%  r   s    rg   r  &RootTransaction._connection_begin_impl
  s    ##D)ry   c                8    U R                   R                  5         g r   )rd   r*  r   s    rg   _connection_rollback_impl)RootTransaction._connection_rollback_impl
  s    &&(ry   c                8    U R                   R                  5         g r   )rd   r/  r   s    rg   _connection_commit_impl'RootTransaction._connection_commit_impl
  s    $$&ry   c                v    U R                   (       a  U R                  5         U R                  R                  (       a$  U R                  R                  R	                  5         U R                   (       d  U(       a  U R                  5         U R                  R                  U L a  S U R                  l        U R                   (       a   eU R                  R                  U Ld   eg ! U R                   (       d  U(       a  U R                  5         U R                  R                  U L a  S U R                  l        f f = fr   )r  r  rd   rS   _cancelr  rQ   )rc   try_deactivates     rg   _close_implRootTransaction._close_impl
  s    
	4~~..02233;;=~~002++t3/3,>>!!++4777 ~~002++t3/3, 4s   A C# #AD8c                $    U R                  5         g r   r  r   s    rg   re  RootTransaction._do_close
  s    ry   c                "    U R                  SS9  g )NT)r  r  r   s    rg   rh  RootTransaction._do_rollback
  s    -ry   c                   U R                   (       a  U R                  R                  U L d   e U R                  5         U R                  R                  (       a$  U R                  R                  R                  5         U R                  5         S U R                  l        OJU R                  R                  U L a  U R                  R                  5         O[        R                  " S5      eU R                   (       a   eU R                  R                  U Ld   eg ! U R                  R                  (       a$  U R                  R                  R                  5         U R                  5         f = f)NThis transaction is inactive)
r  rd   rQ   r  rS   r  r  r   r   r   r   s    rg   rk  RootTransaction._do_commit
  s    >>??//4777	3,,.
 ??66OO77??A002
 ,0DOO(++t3446--.LMM>>!!++4777! ??66OO77??A002s   D AE)Nr  r8  r6  r9  )r  r  r.  r/  )rF  rG  rH  rI  rJ  rZ  rW  rh   r  rN  rb  r  r  r  r  re  rh  rk  rP  r   ry   rg   r   r   Y
  sU    * H+IJ 8 8*)'8 .8ry   r   c                      \ rS rSr% SrSrS\S'   SS jrSSS jjr\	SS j5       r
SS	 jr      SS
 jrSS jrSS jrSS jrSrg)r   i
  aP  Represent a 'nested', or SAVEPOINT transaction.

The :class:`.NestedTransaction` object is created by calling the
:meth:`_engine.Connection.begin_nested` method of
:class:`_engine.Connection`.

When using :class:`.NestedTransaction`, the semantics of "begin" /
"commit" / "rollback" are as follows:

* the "begin" operation corresponds to the "BEGIN SAVEPOINT" command, where
  the savepoint is given an explicit name that is part of the state
  of this object.

* The :meth:`.NestedTransaction.commit` method corresponds to a
  "RELEASE SAVEPOINT" operation, using the savepoint identifier associated
  with this :class:`.NestedTransaction`.

* The :meth:`.NestedTransaction.rollback` method corresponds to a
  "ROLLBACK TO SAVEPOINT" operation, using the savepoint identifier
  associated with this :class:`.NestedTransaction`.

The rationale for mimicking the semantics of an outer transaction in
terms of savepoints so that code may deal with a "savepoint" transaction
and an "outer" transaction in an agnostic way.

.. seealso::

    :ref:`session_begin_nested` - ORM version of the SAVEPOINT API.

)rd   r  
_savepoint_previous_nestedr  r  c                    UR                   c   eUR                  (       a  [        R                  " U5        Xl        U R                  R                  5       U l        SU l        UR                  U l	        Xl        g r  )
rQ   rL   r   r  rd   r5  r  r  rS   r  r^  s     rg   rh   NestedTransaction.__init__
  s_    &&222,, 11*=$//99; * > >)-&ry   c                    U R                   R                  U L a  U R                  U R                   l        g U(       a  [        R                  " S5        g g )Nz7nested transaction already deassociated from connection)rd   rS   r  r!   r  )rc   r  s     rg   r  -NestedTransaction._deactivate_from_connection
  s=    ??..$6262G2GDOO/III ry   c                2    U R                   R                  U L$ r   )rd   rS   r   s    rg   rb  .NestedTransaction._deactivated_from_connection
  s    22$>>ry   c                    SU l         U R                  5         U R                  (       a  U R                  R                  5         g g NF)r  r  r  r  r   s    rg   r  NestedTransaction._cancel
  s7     ((*  !!))+ !ry   c                    U R                   (       ae  U R                  R                  (       aJ  U R                  R                  R                   (       a%  U R                  R                  U R                  5        SU l         U(       a  U R                  US9  U R                   (       a   eU(       a  U R                  R                  U Ld   eg g ! SU l         U(       a  U R                  US9  f f = f)NF)r  )r  rd   rQ   r:  r  r  rS   )rc   deactivate_from_connectionwarn_already_deactives      rg   r  NestedTransaction._close_impl  s    	MOO00OO00::;;DOOL"DN)006K0L>>!!%??66dBBB & #DN)006K0L *s   A6C  C,c                (    U R                  SS5        g )NTFr  r   s    rg   re  NestedTransaction._do_close  s    u%ry   c                (    U R                  SS5        g r  r  r   s    rg   rh  NestedTransaction._do_rollback  s    t$ry   c                L   U R                   (       a>   U R                  R                  U R                  5        SU l         U R	                  5         g U R                  R
                  U L a  U R                  R                  5         g [        R                  " S5      e! SU l         f = f)NFz#This nested transaction is inactive)	r  rd   r?  r  r  rS   r   r   r   r   s    rg   rk  NestedTransaction._do_commit"  s~    >>'77H
 "' ,,.22d:446--9  "'s   %B 	B#)r  r  rd   r  Nr  T)r  r  r.  r/  r6  r8  )r  r  r  r  r.  r/  )rF  rG  rH  rI  rJ  rW  rK  rh   r  rN  rb  r  r  re  rh  rk  rP  r   ry   rg   r   r   
  sg    > NIO. ? ?,C*.CGKC	C(&%ry   r   c                  h   ^  \ rS rSr% SrSrS\S'   SU 4S jjrSS jrSS jr	SS	 jr
SS
 jrSrU =r$ )r   i7  a	  Represent a two-phase transaction.

A new :class:`.TwoPhaseTransaction` object may be procured
using the :meth:`_engine.Connection.begin_twophase` method.

The interface is the same as that of :class:`.Transaction`
with the addition of the :meth:`prepare` method.

)r   _is_preparedr   r   c                >   > SU l         X l        [        TU ]  U5        g r  )r  r   superrh   )rc   rd   r   	__class__s      rg   rh   TwoPhaseTransaction.__init__F  s    !$ry   c                    U R                   (       d  [        R                  " S5      eU R                  R	                  U R
                  5        SU l        g)zaPrepare this :class:`.TwoPhaseTransaction`.

After a PREPARE, the transaction can be committed.

r  TN)r  r   r   rd   rI  r   r  r   s    rg   prepareTwoPhaseTransaction.prepareK  s;     ~~))*HII..txx8 ry   c                :    U R                   R                  U 5        g r   )rd   rC  r   s    rg   r  *TwoPhaseTransaction._connection_begin_implV  s    ,,T2ry   c                d    U R                   R                  U R                  U R                  5        g r   )rd   rO  r   r  r   s    rg   r  -TwoPhaseTransaction._connection_rollback_implY  s     //$:K:KLry   c                d    U R                   R                  U R                  U R                  5        g r   )rd   rS  r   r  r   s    rg   r  +TwoPhaseTransaction._connection_commit_impl\  s     --dhh8I8IJry   )r  r   )rd   rG   r   r   r8  )rF  rG  rH  rI  rJ  rW  rK  rh   r  r  r  r  rP  __classcell__)r  s   @rg   r   r   7  s5     (I	H%
	!3MK Kry   r   c                  n   \ rS rSr% SrS\S'   S\S'   \rS\S'   S	rS
\S'   \	r
S\S'   SrS\S'   S	rS
\S'   SrS\S'   S\S'   S\S'   S\S'   S\S'   S
\S'        S3               S4S jjrS5S jr\S6S  j5       rS7S! jrS8S" jr\S#S#S#S#S#S$.             S9S% jj5       r\S:S& j5       rS:S' jrS;S( jr\S<S) j5       r\S<S* j5       r\R4                  " 5       rS<S+ jrS=S>S, jjr\R>                   S?   S@S- jj5       r \R>                  SAS. j5       r!        SBS/ jr"SCS0 jr#SDS1 jr$S2r%g)Er,  i`  a^  
Connects a :class:`~sqlalchemy.pool.Pool` and
:class:`~sqlalchemy.engine.interfaces.Dialect` together to provide a
source of database connectivity and behavior.

An :class:`_engine.Engine` object is instantiated publicly using the
:func:`~sqlalchemy.create_engine` function.

.. seealso::

    :doc:`/core/engines`

    :ref:`connections_toplevel`

rJ   rK   r3  r  r,   rO   Fr  ra   zType[Connection]_connection_clszsqlalchemy.engine.Enginer  rL  
_is_futureNr0  r   zType[OptionEngine]_option_clsr/   rI   r6   r  r2   urlr  c	                   Xl         X0l        X l        U(       a  X@l        XPl        Xl        US:w  a$  [        R                  " X`R                  S9U l	        OS U l	        [        R                  " XS9  U(       a  U R                  " S0 UD6  g g )Nr   )
size_alertechoflagr   )r  r  rI   logging_nameechor  r!   LRUCache_lru_size_alertr  r    instance_loggerupdate_execution_options)	rc   r  rI   r  r  r  query_cache_sizer   r  s	            rg   rh   Engine.__init__  s{     	 ,	.q #'== -A-A$D  $(D D0))>,=> ry   c                    U R                  5       (       a1  U R                  R                  S[        U5      UR                  5        g g )NziCompiled cache size pruning from %d items to %d.  Increase cache size to reduce the frequency of pruning.)r^   rp   rq   r  capacity)rc   caches     rg   r  Engine._lru_size_alert  s<      ""KKJE
	 #ry   c                    U $ )zReturns this :class:`.Engine`.

Used for legacy schemes that accept :class:`.Connection` /
:class:`.Engine` objects within the same variable.

r   r   s    rg   rU   Engine.engine  s	     ry   c                \    U R                   (       a  U R                   R                  5         gg)a[  Clear the compiled cache associated with the dialect.

This applies **only** to the built-in cache that is established
via the :paramref:`_engine.create_engine.query_cache_size` parameter.
It will not impact any dictionary caches that were passed via the
:paramref:`.Connection.execution_options.compiled_cache` parameter.

.. versionadded:: 1.4

N)r  clearr   s    rg   clear_compiled_cacheEngine.clear_compiled_cache  s$       &&(  ry   c                    U R                   R                  X5        U R                  R                  U5      U l        U R                  R                  X5        g)a  Update the default execution_options dictionary
of this :class:`_engine.Engine`.

The given keys/values in \**opt are added to the
default execution options that will be used for
all connections.  The initial contents of this dictionary
can be sent via the ``execution_options`` parameter
to :func:`_sa.create_engine`.

.. seealso::

    :meth:`_engine.Connection.execution_options`

    :meth:`_engine.Engine.execution_options`

N)rK   set_engine_execution_optionsrO   r   rI   r   s     rg   r  Engine.update_execution_options  sA    " 	224="&"9"9"?"?"D11$<ry   .)r   r   r   r   r   c                   g r   r   )rc   r   r   r   r   r   r   s          rg   r   Engine.execution_options  s     ry   c                    g r   r   r   s     rg   r   r    s    =@ry   c                $    U R                  X5      $ )a?  Return a new :class:`_engine.Engine` that will provide
:class:`_engine.Connection` objects with the given execution options.

The returned :class:`_engine.Engine` remains related to the original
:class:`_engine.Engine` in that it shares the same connection pool and
other state:

* The :class:`_pool.Pool` used by the new :class:`_engine.Engine`
  is the
  same instance.  The :meth:`_engine.Engine.dispose`
  method will replace
  the connection pool instance for the parent engine as well
  as this one.
* Event listeners are "cascaded" - meaning, the new
  :class:`_engine.Engine`
  inherits the events of the parent, and new events can be associated
  with the new :class:`_engine.Engine` individually.
* The logging configuration and logging_name is copied from the parent
  :class:`_engine.Engine`.

The intent of the :meth:`_engine.Engine.execution_options` method is
to implement schemes where multiple :class:`_engine.Engine`
objects refer to the same connection pool, but are differentiated
by options that affect some execution-level behavior for each
engine.    One such example is breaking into separate "reader" and
"writer" :class:`_engine.Engine` instances, where one
:class:`_engine.Engine`
has a lower :term:`isolation level` setting configured or is even
transaction-disabled using "autocommit".  An example of this
configuration is at :ref:`dbapi_autocommit_multiple`.

Another example is one that
uses a custom option ``shard_id`` which is consumed by an event
to change the current schema on a database connection::

    from sqlalchemy import event
    from sqlalchemy.engine import Engine

    primary_engine = create_engine("mysql+mysqldb://")
    shard1 = primary_engine.execution_options(shard_id="shard1")
    shard2 = primary_engine.execution_options(shard_id="shard2")

    shards = {"default": "base", "shard_1": "db1", "shard_2": "db2"}


    @event.listens_for(Engine, "before_cursor_execute")
    def _switch_shard(conn, cursor, stmt, params, context, executemany):
        shard_id = conn.get_execution_options().get("shard_id", "default")
        current_shard = conn.info.get("current_shard", None)

        if current_shard != shard_id:
            cursor.execute("use %s" % shards[shard_id])
            conn.info["current_shard"] = shard_id

The above recipe illustrates two :class:`_engine.Engine` objects that
will each serve as factories for :class:`_engine.Connection` objects
that have pre-established "shard_id" execution options present. A
:meth:`_events.ConnectionEvents.before_cursor_execute` event handler
then interprets this execution option to emit a MySQL ``use`` statement
to switch databases before a statement execution, while at the same
time keeping track of which database we've established using the
:attr:`_engine.Connection.info` dictionary.

.. seealso::

    :meth:`_engine.Connection.execution_options`
    - update execution options
    on a :class:`_engine.Connection` object.

    :meth:`_engine.Engine.update_execution_options`
    - update the execution
    options for a given :class:`_engine.Engine` in place.

    :meth:`_engine.Engine.get_execution_options`


)r  r   s     rg   r   r    s    \ **ry   c                    U R                   $ )zGet the non-SQL options which will take effect during execution.

.. versionadded: 1.3

.. seealso::

    :meth:`_engine.Engine.execution_options`
r   r   s    rg   r   Engine.get_execution_options6  r   ry   c                .    U R                   R                  $ )zcString name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
in use by this :class:`Engine`.

)rI   r   r   s    rg   r   Engine.nameA  s     ||   ry   c                .    U R                   R                  $ )zcDriver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
in use by this :class:`Engine`.

)rI   driverr   s    rg   r  Engine.driverJ  s     ||"""ry   c                $    SU R                   < S3$ )NzEngine(r  )r  r   s    rg   __repr__Engine.__repr__U  s    #xx))ry   c                    U(       a  U R                   R                  5         U R                   R                  5       U l         U R                  R	                  U 5        g)aA  Dispose of the connection pool used by this
:class:`_engine.Engine`.

A new connection pool is created immediately after the old one has been
disposed. The previous connection pool is disposed either actively, by
closing out all currently checked-in connections in that pool, or
passively, by losing references to it but otherwise not closing any
connections. The latter strategy is more appropriate for an initializer
in a forked Python process.

:param close: if left at its default of ``True``, has the
 effect of fully closing all **currently checked in**
 database connections.  Connections that are still checked out
 will **not** be closed, however they will no longer be associated
 with this :class:`_engine.Engine`,
 so when they are closed individually, eventually the
 :class:`_pool.Pool` which they are associated with will
 be garbage collected and they will be closed out fully, if
 not already closed on checkin.

 If set to ``False``, the previous connection pool is de-referenced,
 and otherwise not touched in any way.

.. versionadded:: 1.4.33  Added the :paramref:`.Engine.dispose.close`
    parameter to allow the replacement of a connection pool in a child
    process without interfering with the connections used by the parent
    process.


.. seealso::

    :ref:`engine_disposal`

    :ref:`pooling_multiprocessing`

N)r  disposerecreaterK   engine_disposed)rc   r   s     rg   r  Engine.disposeX  s>    J IIII&&(	%%d+ry   c              #  x   #    Uc  U R                  5        nUv   S S S 5        g Uv   g ! , (       d  f       g = f7fr   )connect)rc   rd   rY  s      rg   _optional_conn_ctx_manager!Engine._optional_conn_ctx_manager  s3      4
     s   :):
7:c              #     #    U R                  5        nUR                  5          Uv   SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f7f)a  Return a context manager delivering a :class:`_engine.Connection`
with a :class:`.Transaction` established.

E.g.::

    with engine.begin() as conn:
        conn.execute(text("insert into table (x, y, z) values (1, 2, 3)"))
        conn.execute(text("my_special_procedure(5)"))

Upon successful operation, the :class:`.Transaction`
is committed.  If an error is raised, the :class:`.Transaction`
is rolled back.

.. seealso::

    :meth:`_engine.Engine.connect` - procure a
    :class:`_engine.Connection` from
    an :class:`_engine.Engine`.

    :meth:`_engine.Connection.begin` - start a :class:`.Transaction`
    for a particular :class:`_engine.Connection`.

N)r  r   )rc   rY  s     rg   r   Engine.begin  s9     2 \\^t
  ^ ^s/   AA:A	A
A	A
AAc                ~    U R                  5        nUR                  " X40 UD6  S S S 5        g ! , (       d  f       g = fr   )r   r'  )rc   r$  r%  r&  rY  s        rg   r'  Engine._run_ddl_visitor  s,     ZZ\T!!/EfE \\s   .
<c                $    U R                  U 5      $ )a  Return a new :class:`_engine.Connection` object.

The :class:`_engine.Connection` acts as a Python context manager, so
the typical use of this method looks like::

    with engine.connect() as connection:
        connection.execute(text("insert into table values ('foo')"))
        connection.commit()

Where above, after the block is completed, the connection is "closed"
and its underlying DBAPI resources are returned to the connection pool.
This also has the effect of rolling back any transaction that
was explicitly begun or was begun via autobegin, and will
emit the :meth:`_events.ConnectionEvents.rollback` event if one was
started and is still in progress.

.. seealso::

    :meth:`_engine.Engine.begin`

)r  r   s    rg   r  Engine.connect  s    . ##D))ry   c                6    U R                   R                  5       $ )a  Return a "raw" DBAPI connection from the connection pool.

The returned object is a proxied version of the DBAPI
connection object used by the underlying driver in use.
The object will have all the same behavior as the real DBAPI
connection, except that its ``close()`` method will result in the
connection being returned to the pool, rather than being closed
for real.

This method provides direct DBAPI connection access for
special situations when the API provided by
:class:`_engine.Connection`
is not needed.   When a :class:`_engine.Connection` object is already
present, the DBAPI connection is available using
the :attr:`_engine.Connection.connection` accessor.

.. seealso::

    :ref:`dbapi_connections`

)r  r  r   s    rg   rV   Engine.raw_connection  s    , yy  ""ry   )r  rO   rI   r  r  r  r  r  )NNi  NF)r  r6   rI   r/   r  r2   r  r1  r  zOptional[_EchoFlagType]r  r4  r   zOptional[Mapping[str, Any]]r  r  )r  zutil.LRUCache[Any, Any]r.  r/  )r.  r,  r8  r   r   r.  r/  )r   r3  r   r  r   r   r   r4  r   r0  r   r   r.  OptionEngine)r   r   r.  r  r5  )r.  r  r  )r   r  r.  r/  r   )rd   rV  r.  Iterator[Connection])r.  r	  rE  r2  r7  )&rF  rG  rH  rI  rJ  rK  rD   rO   ra   rG   r  rL  r  r   rh   r  rN  rU   r  r  r   r   r   r   r  r    echo_propertyr  r  r  
contextlibcontextmanagerr  r   r'  r  rV   rP  r   ry   rg   r,  r,  `  sD     1000*??K(2O%2"<C<J>B;B##
J	H '+(, #9= %?? ? 	?
 $? &? ? 7? ?8  )=*  7: *-*-AD	 4	 		
 (	 %(	 ?	 	 
	 	 @ @N+`	' ! ! # # D*(,T 15.	   8F,F !F 	F
 
F*2#ry   r,  c                     \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'   S\S'   S\S'   S\S'       SS jrSS jr\R                  (       d?  \
SS j5       r\R                  SS j5       r\
SS j5       r\R                  SS j5       rSrgSrg)OptionEngineMixini  FrJ   rK   r3  r  r/   rI   r6   r  r2   r  r  r  zlog.echo_propertyr  c                   Xl         UR                  U l        UR                  U l        UR                  U l        UR                  U l        UR
                  U l        UR                  U l        [        R                  " X R                  S9  U R                  R                  UR                  5      U l	        UR                  U l        U R                  " S0 UD6  g )Nr  r   )_proxiedr  rI   r  r  r  r  r    r  rK   r`   rO   r  )rc   proxiedr   s      rg   rh   OptionEngineMixin.__init__  s      ;;#00LL	&66&66D995 ++G,<,<=")"<"<%%:(9:ry   c                    [        5       er   r\  r   s     rg   r  *OptionEngineMixin.update_execution_options  r`  ry   c                .    U R                   R                  $ r   r  r  r   s    rg   r  OptionEngineMixin.pool  s    ==%%%ry   c                $    XR                   l        g r   r  )rc   r  s     rg   r  r    s    !%MMry   c                t    U R                   R                  =(       d    U R                  R                  SS5      $ )Nra   F)r  ra   __dict__r   r   s    rg   ra   OptionEngineMixin._has_events  s/    ==,, 0A0Au1 ry   c                     XR                   S'   g )Nra   )r  )rc   r   s     rg   ra   r     s    +0MM-(ry   )	r  rO   r  rI   rK   r  r  r  r  N)r  r,  r   r.   r  )r.  r6   )r  r6   r.  r/  r6  )r   r  r.  r/  )rF  rG  rH  rI  _sa_propagate_class_eventsrK  rh   r  typingTYPE_CHECKINGrN  r  setterra   rP  r   ry   rg   r  r    s    !&0000
J	H
;;2M;:$  
	& 
	& 
	& 
	& 
	 
	
 
			1 
	1%  ry   r  c                      \ rS rSrSS jrSrg)r  i%  c                2    [         R                  " U 40 UD6  g r   )r,  r  r   s     rg   r  %OptionEngine.update_execution_options&  s    ''44ry   r   Nr  )rF  rG  rH  rI  r  rP  r   ry   rg   r  r  %  s    5ry   r  )brJ  
__future__r   r  r	  r  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   
interfacesr   r   r   r   r   r   r   r!   r   r   r   r   r   r   r    sqlr"   r  r  r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   
reflectionr1   r  r2   eventr3   r4   r  r5   r6   r7   r8   sql._typingr9   sql.compilerr:   sql.ddlr;   r<   sql.functionsr=   
sql.schemar>   r?   r@   sql.selectablerA   rB   
EMPTY_DICTrD   rK  rE   InspectablerG   r  rY  r   r   r   
Identifiedr,  r  r  r  r   ry   rg   <module>r2     s   #  
                " . # ( $ ( & $ % &      "	-213425+-7#2%"#', ''.'/-*,1 T)-  8 $
 /A%#')?)?)L A%#HJ,'+ ,'^M& M`i8k i8Xo od&K/ &KRA#CNNJ,B,B;,OA#H>1 >1B5$f 5
 " ry   