Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/engine/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/engine/__pycache__/base.cpython-311.pyc

�

�܋fpT��|�ddlmZddlZddlZddlmZddlmZddlmZddl	m
Z
dd	l	mZdd
l	mZddl	mZddlm
Z
ddlmZ	Gd
�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�deej��ZGd�de��ZdS)�)�with_statementN�)�Connectable)�ExceptionContext)�_distill_params�)�exc)�
interfaces)�log)�util)�schemac�>�eZdZdZejd��Z							d=d�Zd�Ze	d���Z
d�Zd�Zd	�Z
d
�Zd�Ze	d���Ze	d
���Ze	d���Zd�Ze	d���Zd�Ze	d���Ze	d���Ze	d���Zd�Zd�Zd>d�Zd�Zd�Zd�Zd>d�Zd�Z d?d�Z!d?d�Z"d�Z#d �Z$d!�Z%d?d"�Z&d>d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,d)�Z-d*�Z.d+�Z/d,�Z0d-�Z1d.�Z2d/�Z3d0�Z4d1�Z5d2�Z6d3�Z7d4�Z8d5�Z9d>d6�Z:d7�Z;dZ<dZ=d8�Z>e?d9���Z@d:�ZAd;�ZBd<�ZCdS)@�
ConnectionaIProvides high-level functionality for a wrapped DB-API connection.

    Provides execution support for string-based SQL statements as well as
    :class:`_expression.ClauseElement`, :class:`.Compiled` and
    :class:`.DefaultGenerator`
    objects. Provides a :meth:`begin` method to return :class:`.Transaction`
    objects.

    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

    NFc��||_|j|_||_|du|_|rA||_||_|j|_d|_||_|j	|_	|j
|_
n�|�|n|���|_d|_d|_
||_d|_d|_|j���|_|�$|j�|j��|_|p
|duo|j	|_	|rJ�|j|_|j	s|jj	r"|j�||j��dSdS)z�Construct a new Connection.

        The constructor here is not public and is only called only by an
        :class:`_engine.Engine`. See :meth:`_engine.Engine.connect` and
        :meth:`_engine.Engine.contextual_connect` methods.

        NFrT)�engine�dialect�_Connection__branch_from�_Connection__branch�_Connection__connection�_execution_options�_echo�should_close_with_result�dispatch�_has_events�schema_for_object�raw_connection�_Connection__transaction�_Connection__savepoint_seq�_Connection__invalid�_Connection__can_reconnect�_should_log_info�_join�engine_connect)�selfr�
connection�close_with_result�_branch_fromr�	_dispatchrs        �M/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/engine/base.py�__init__zConnection.__init__Fsr��"����~���)���$�D�0��
��	@� *�D��&8�D�#�%�+�D�J�,1�D�)�%�D�M�+�7�D��%1�%C�D�"�"��)��
��*�*�,�,�
��
"&�D��#$�D� �,=�D�)�"�D�N�#'�D� ���5�5�7�7�D�J��"�!%�
� 3� 3�F�O� D� D��
�*� ��t�#�:��(:�
��*�)�)�)�&,�&?�D�#���	>�t�{�6�	>��M�(�(��t�}�=�=�=�=�=�	>�	>�c��|jr|j���S|j�|j|j||j|j|j���S)a�Return a new Connection which references this Connection's
        engine and connection; but does not have close_with_result enabled,
        and also whose close() method does nothing.

        The Core uses this very sparingly, only in the case of
        custom SQL default functions that are to be INSERTed as the
        primary key of a row where we need to get the value back, so we have
        to invoke it distinctly - this is a very uncommon case.

        Userland code accesses _branch() when the connect() or
        contextual_connect() methods are called.  The branched connection
        acts as much as possible like the parent, except that it stays
        connected when a close() event occurs.

        )r'rrr()r�_branchr�_connection_clsrrrr�r$s r)r-zConnection._branch�sb�� ��
	��%�-�-�/�/�/��;�.�.����!�!�#'�#:� �,��-�
/���
r+c�"�|jr|jS|S)z�Return the 'root' connection.

        Returns 'self' if this connection is not a branch, else
        returns the root connection from which we ultimately branched.

        )rr/s r)�_rootzConnection._root�s����	��%�%��Kr+c��|j�|j��}|j���|_|S)z)Create a shallow copy of this Connection.)�	__class__�__new__�__dict__�copy)r$�cs  r)�_clonezConnection._clone�s5��
�N�"�"�4�>�2�2���]�'�'�)�)��
��r+c��|S�N�r/s r)�	__enter__zConnection.__enter__�����r+c�.�|���dSr:)�close�r$�type_�value�	tracebacks    r)�__exit__zConnection.__exit__�s���
�
�����r+c��|���}|j�|��|_|js|jjr|j�||��|j�||��|S)a� Set non-SQL options for the connection which take effect
        during execution.

        The method returns a copy of this :class:`_engine.Connection`
        which references
        the same underlying DBAPI connection, but also defines the given
        execution options which will take effect for a call to
        :meth:`execute`. As the new :class:`_engine.Connection`
        references the same
        underlying resource, it's usually a good idea to ensure that the copies
        will be discarded immediately, which is implicit if used as in::

            result = connection.execution_options(stream_results=True).\
                                execute(stmt)

        Note that any key/value can be passed to
        :meth:`_engine.Connection.execution_options`,
        and it will be stored in the
        ``_execution_options`` dictionary of the :class:`_engine.Connection`.
        It
        is suitable for usage by end-user schemes to communicate with
        event listeners, for example.

        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 autocommit: Available on: Connection, statement.
          When True, a COMMIT will be invoked after execution
          when executed in 'autocommit' mode, i.e. when an explicit
          transaction is not begun on the connection.   Note that this
          is **library level, not DBAPI level autocommit**.  The DBAPI
          connection will remain in a real transaction unless the
          "AUTOCOMMIT" isolation level is used.

          .. deprecated:: 1.4  The library-level "autocommit" feature is being
             removed in favor of database driver "autocommit" which is
             now widely available.  See the section :ref:`dbapi_autocommit`.

        :param compiled_cache: Available on: Connection.
          A dictionary where :class:`.Compiled` objects
          will be cached when the :class:`_engine.Connection`
          compiles a clause
          expression into a :class:`.Compiled` object.
          It is the user's responsibility to
          manage the size of this dictionary, which will have keys
          corresponding to the dialect, clause element, the column
          names within the VALUES or SET clause of an INSERT or UPDATE,
          as well as the "batch" mode for an INSERT or UPDATE statement.
          The format of this dictionary is not guaranteed to stay the
          same in future releases.

          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 isolation_level: Available on: :class:`_engine.Connection`.

          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**, not just the copy that is
          returned by the call to :meth:`_engine.Connection.execution_options`
          method.  The isolation level will remain at the given setting until
          the DBAPI connection itself is returned to the connection pool, i.e.
          the :meth:`_engine.Connection.close` method on the original
          :class:`_engine.Connection` is called,
          where  an event handler will emit
          additional statements on the DBAPI connection in order to revert the
          isolation level change.

          .. warning::  The ``isolation_level`` execution option should
             **not** be used when a transaction is already established, that
             is, the :meth:`_engine.Connection.begin`
             method or similar has been
             called.  A database cannot change the isolation level on a
             transaction in progress, and different DBAPIs and/or
             SQLAlchemy dialects may implicitly roll back or commit
             the transaction, or not affect the connection at all.

          .. 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 isolation level re-applied
             to it automatically.

          .. seealso::

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

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

                :ref:`SQLite Transaction Isolation <sqlite_isolation_level>`

                :ref:`PostgreSQL Transaction Isolation <postgresql_isolation_level>`

                :ref:`MySQL Transaction Isolation <mysql_isolation_level>`

                :ref:`SQL Server Transaction Isolation <mssql_isolation_level>`

                :ref:`session_transaction_isolation` - for the ORM

        :param no_parameters: 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: Connection, statement.
          Indicate to the dialect that results should be
          "streamed" and not pre-buffered, if possible.  This is a limitation
          of many DBAPIs.  The flag is currently understood only by the
          psycopg2, mysqldb and pymysql dialects.

        :param schema_translate_map: Available on: Connection, Engine.
          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.

          .. versionadded:: 1.1

          .. seealso::

            :ref:`schema_translating`

        .. seealso::

            :meth:`_engine.Engine.execution_options`

            :meth:`.Executable.execution_options`

            :meth:`_engine.Connection.get_execution_options`


        )r8r�unionrrr� set_connection_execution_optionsr)r$�optr7s   r)�execution_optionszConnection.execution_options�sy��x
�K�K�M�M�� �3�9�9�#�>�>�����	C�t�{�6�	C��M�:�:�1�c�B�B�B���5�5�a��=�=�=��r+c��|jS)z�Get the non-SQL options which will take effect during execution.

        .. versionadded:: 1.3

        .. seealso::

            :meth:`_engine.Connection.execution_options`
        �rr/s r)�get_execution_optionsz Connection.get_execution_optionsZ�
���&�&r+c�$�d|jvo|jS)z)Return True if this connection is closed.r)r5r r/s r)�closedzConnection.closedes!��

&�T�]�:�
)��(�(�	
r+c��|jjS)z/Return True if this connection was invalidated.)r1rr/s r)�invalidatedzConnection.invalidatedns���z�#�#r+c��	|jS#t$rYnwxYw	|���S#t$r$}|�|dddd��Yd}~dSd}~wwxYw)z�The underlying DB-API connection managed by this Connection.

        .. seealso::


            :ref:`dbapi_connections`

        N)r�AttributeError�_revalidate_connection�
BaseException�_handle_dbapi_exception�r$�es  r)r%zConnection.connectionts���	��$�$���	�	�	�
�D�	����	D��.�.�0�0�0���	D�	D�	D��(�(��D�$��d�C�C�C�C�C�C�C�C�C�����	D���s �	�
��.�
A�A�Ac��	|j�|j��S#t$r$}|�|dddd��Yd}~dSd}~wwxYw)a�Return the current isolation level assigned to this
        :class:`_engine.Connection`.

        This will typically be the default isolation level as determined
        by the dialect, unless if the
        :paramref:`.Connection.execution_options.isolation_level`
        feature has been used to alter the isolation level on a
        per-:class:`_engine.Connection` basis.

        This attribute will typically perform a live SQL operation 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.  Compare to the
        :attr:`_engine.Connection.default_isolation_level` accessor
        which returns the dialect-level setting without performing a SQL
        query.

        .. versionadded:: 0.9.9

        .. 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)r�get_isolation_levelr%rUrVrWs  r)rZzConnection.get_isolation_level�sr��@	D��<�3�3�D�O�D�D�D���	D�	D�	D��(�(��D�$��d�C�C�C�C�C�C�C�C�C�����	D���s�!�
A�A
�
Ac��|jjS)aCThe default isolation level assigned to this
        :class:`_engine.Connection`.

        This is the isolation level setting that the
        :class:`_engine.Connection`
        has when first procured via the :meth:`_engine.Engine.connect` method.
        This level stays in place until the
        :paramref:`.Connection.execution_options.isolation_level` is used
        to change the setting on a per-:class:`_engine.Connection` basis.

        Unlike :meth:`_engine.Connection.get_isolation_level`,
        this attribute is set
        ahead of time from the first connection procured by the dialect,
        so SQL query is not invoked when this accessor is called.

        .. versionadded:: 0.9.9

        .. seealso::

            :meth:`_engine.Connection.get_isolation_level`
            - view current 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

        )r�default_isolation_levelr/s r)r\z"Connection.default_isolation_level�s��>�|�3�3r+c��|jr|j���S|jrP|jrI|j�tjd���|j�|���|_	d|_|j	Stj
d���)Nz8Can't reconnect until invalid transaction is rolled back)�_connectionF�This Connection is closed)rrTr rrr	�InvalidRequestErrorrrr�ResourceClosedErrorr/s r)rTz!Connection._revalidate_connection�s�����	?��%�<�<�>�>�>���	%�D�N�	%��!�-��-�1����!%�� :� :�t� :� L� L�D��"�D�N��$�$��%�&A�B�B�Br+c�.�t|jdd��S�N�is_validF)�getattrrr/s r)�_connection_is_validzConnection._connection_is_valid�s���t�(�*�e�<�<�<r+c�N�|jo|jot|jdd��Src)rOrQrerr/s r)�#_still_open_and_connection_is_validz.Connection._still_open_and_connection_is_valid�s5����O�
>��$�$�
>���)�:�u�=�=�	
r+c��|jjS)a�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`.

        )r%�infor/s r)rjzConnection.info�s����#�#r+c�*�|���S)a�Returns a branched version of this :class:`_engine.Connection`.

        The :meth:`_engine.Connection.close` method on the returned
        :class:`_engine.Connection` can be called and this
        :class:`_engine.Connection` will remain open.

        This method provides usage symmetry with
        :meth:`_engine.Engine.connect`, including for usage
        with context managers.

        �r-r/s r)�connectzConnection.connect�s���|�|�~�~�r+c�*�|���Sr:rl�r$�kwargss  r)�_contextual_connectzConnection._contextual_connects���|�|�~�~�r+c���|jrdS|jrtjd���|jjr|jj�|��|j`d|j_dS)aInvalidate the underlying DBAPI connection associated with
        this :class:`_engine.Connection`.

        The underlying DBAPI connection is literally closed (if
        possible), and is discarded.  Its source connection pool will
        typically lazily create a new connection to replace it.

        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.

        .. seealso::

            :ref:`pool_connection_invalidation`

        Nr_T)	rQrOr	rar1rfr�
invalidater)r$�	exceptions  r)rszConnection.invalidatesp��R��	��F��;�	G��)�*E�F�F�F��:�*�	:��J�#�.�.�y�9�9�9��J�#�#��
���r+c�8�|j���dS)a,Detach the underlying DB-API connection from its connection pool.

        E.g.::

            with engine.connect() as conn:
                conn.detach()
                conn.execute("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).

        N)r�detachr/s r)rvzConnection.detachBs��4	
�� � �"�"�"�"�"r+c��|jr|j���S|j�t|��|_|jSt	||j��S)aWBegin a transaction and return a transaction handle.

        The returned object is an instance of :class:`.Transaction`.
        This object represents the "scope" of the transaction,
        which completes when either the :meth:`.Transaction.rollback`
        or :meth:`.Transaction.commit` method is called.

        Nested calls to :meth:`.begin` on the same :class:`_engine.Connection`
        will return new :class:`.Transaction` objects that represent
        an emulated transaction within the scope of the enclosing
        transaction, that is::

            trans = conn.begin()   # outermost transaction
            trans2 = conn.begin()  # "nested"
            trans2.commit()        # does nothing
            trans.commit()         # actually commits

        Calls to :meth:`.Transaction.commit` only have an effect
        when invoked via the outermost :class:`.Transaction` object, though the
        :meth:`.Transaction.rollback` method of any of the
        :class:`.Transaction` objects will roll back the
        transaction.

        .. seealso::

            :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`

        )r�beginr�RootTransaction�Transactionr/s r)rxzConnection.begin^sZ��F��	.��%�+�+�-�-�-���%�!0��!6�!6�D���%�%��t�T�%7�8�8�8r+c��|jr|j���S|j�t|��|_nt	||j��|_|jS)a9Begin a nested transaction and return a transaction handle.

        The returned object is an instance of :class:`.NestedTransaction`.

        Nested transactions require SAVEPOINT support in the
        underlying database.  Any transaction in the hierarchy may
        ``commit`` and ``rollback``, however the outermost transaction
        still controls the overall ``commit`` or ``rollback`` of the
        transaction of a whole.

        .. seealso::

            :meth:`_engine.Connection.begin`

            :meth:`_engine.Connection.begin_twophase`

        )r�begin_nestedrry�NestedTransactionr/s r)r|zConnection.begin_nested�s^��$��	5��%�2�2�4�4�4���%�!0��!6�!6�D���!2�4��9K�!L�!L�D���!�!r+c���|jr|j�|���S|j�tjd���|�|jj���}t||��|_|jS)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`

        )�xidNzOCannot start a two phase transaction when a transaction is already in progress.)	r�begin_twophaserr	r`rr�
create_xid�TwoPhaseTransaction�r$rs  r)r�zConnection.begin_twophase�s���(��	>��%�4�4��4�=�=�=���)��)�*���
��;��+�%�0�0�2�2�C�0��s�;�;����!�!r+c�@�|jj�|��Sr:)rr�do_recover_twophaser/s r)�recover_twophasezConnection.recover_twophase�s���{�"�6�6�t�<�<�<r+c�J�|jj�|||���dS�N)�recover)rr�do_rollback_twophase�r$rr�s   r)�rollback_preparedzConnection.rollback_prepared�s(�����0�0��s�G�0�L�L�L�L�Lr+c�J�|jj�|||���dSr�)rr�do_commit_twophaser�s   r)�commit_preparedzConnection.commit_prepared�s(�����.�.�t�S�'�.�J�J�J�J�Jr+c��|jjduS)z,Return True if a transaction is in progress.N)r1rr/s r)�in_transactionzConnection.in_transaction�s���z�'�t�3�3r+c��|jrJ�|jr|jj�d��|js|jjr|j�|��	|jj�	|j
��|j
j�||j
_dSdS#t$r$}|�
|dddd��Yd}~dSd}~wwxYw)NzBEGIN (implicit))rrr�loggerrjrrrxr�do_beginr%�_reset_agentrUrV)r$�transactionrXs   r)�_begin_implzConnection._begin_impl�s����%�%�%�%��:�	8��K��#�#�$6�7�7�7���	&�t�{�6�	&��M����%�%�%�	D��K��(�(���9�9�9���+�3�/:���,�,�,�4�3���	D�	D�	D��(�(��D�$��d�C�C�C�C�C�C�C�C�C�����	D���s�<B�
C�(C�Cc�H�|jrJ�|js|jjr|j�|��|jr�|jr|jj�d��	|jj	�
|j��n0#t$r#}|�
|dddd��Yd}~nd}~wwxYw|js|jj|jurd|j_d|_dS#|js|jj|jurd|j_d|_wxYwd|_dS)N�ROLLBACK)rrrr�rollbackrhrr�rjr�do_rollbackr%rUrVrr�rrWs  r)�_rollback_implzConnection._rollback_impl�s`���%�%�%�%���	)�t�{�6�	)��M�"�"�4�(�(�(��3�	&��z�
4���"�'�'�
�3�3�3�

*���#�/�/���@�@�@�@�� �
H�
H�
H��,�,�Q��d�D�$�G�G�G�G�G�G�G�G�����
H������8���4��8J�J�J�37�D�O�0�%)��"�"�"��	��8���4��8J�J�J�37�D�O�0�%)��"�)�)�)�)�!%�D���s0�%$B
�	C)�

B7�B2�-C)�2B7�7C)�)/Dc�(�|jrJ�|js|jjr|j�|��|jr|jj�d��	|jj�	|j
��n0#t$r#}|�|dddd��Yd}~nd}~wwxYw|j
s|j
j|jurd|j
_d|_dS#|j
s|j
j|jurd|j
_d|_wxYw)N�COMMIT)rrrr�commitrr�rjr�	do_commitr%rUrVrr�r)r$�
autocommitrXs   r)�_commit_implzConnection._commit_impl�sG���%�%�%�%���	'�t�{�6�	'��M� � ��&�&�&��:�	.��K��#�#�H�-�-�-�
	&��K��)�)�$�/�:�:�:�:���	D�	D�	D��(�(��D�$��d�C�C�C�C�C�C�C�C�����	D�����N�
4��O�0�D�4F�F�F�/3���,�!%�D�����	�N�
4��O�0�D�4F�F�F�/3���,�!%�D��%�%�%�%s0�$B�C"�
B0�
B+�&C"�+B0�0C"�"/Dc��|jrJ�|js|jjr|j�||��|�|xjdz
c_d|jz}|jr"|jj�||��|SdS)Nrzsa_savepoint_%s)	rrrr�	savepointrrhr�do_savepoint)r$�names  r)�_savepoint_implzConnection._savepoint_impls����%�%�%�%���	0�t�{�6�	0��M�#�#�D�$�/�/�/��<�� � �A�%� � �$�t�';�;�D��3�	��K��,�,�T�4�8�8�8��K�	�	r+c��||jur|j|urd|_n|j|_|jr|jj|urd|j_dSdSdSr:)r�_parentrhrr�)r$�transs  r)�_discard_transactionzConnection._discard_transactionso���D�&�&�&��}��%�%�%)��"�"�%*�]��"��3�	6�� �-��6�6�15��!�.�.�.�	6�	6�6�6r+c���|jrJ�|js|jjr|j�|||��|jr |jj�||��||_dSr:)	rrrr�rollback_savepointrhr�do_rollback_to_savepointr�r$r��contexts   r)�_rollback_to_savepoint_implz&Connection._rollback_to_savepoint_impl&sy���%�%�%�%���	B�t�{�6�	B��M�,�,�T�4��A�A�A��3�	E��K��8�8��t�D�D�D�$����r+c���|jrJ�|js|jjr|j�|||��|jr |jj�||��||_dSr:)	rrrr�release_savepointrhr�do_release_savepointrr�s   r)�_release_savepoint_implz"Connection._release_savepoint_impl0sy���%�%�%�%���	A�t�{�6�	A��M�+�+�D�$��@�@�@��3�	A��K��4�4�T�4�@�@�@�$����r+c�Z�|jrJ�|jr|jj�d��|js|jjr |j�||j��|j	r?|jj
�||j��|jj
�||j_
dSdSdS)NzBEGIN TWOPHASE (implicit))rrrr�rjrrr�rrhr�do_begin_twophaser%r�)r$r�s  r)�_begin_twophase_implzConnection._begin_twophase_impl:s����%�%�%�%��:�	A��K��#�#�$?�@�@�@���	@�t�{�6�	@��M�(�(��{��?�?�?��3�	;��K��1�1�$���H�H�H���+�3�/:���,�,�,�		;�	;�4�3r+c��|jrJ�|js|jjr|j�||��|jr>t
|jt��sJ�|jj	�
||��dSdSr:)rrrr�prepare_twophaserh�
isinstancerr�r�do_prepare_twophaser�s  r)�_prepare_twophase_implz!Connection._prepare_twophase_implHs����%�%�%�%���	6�t�{�6�	6��M�*�*�4��5�5�5��3�	?��d�0�2E�F�F�F�F�F��K��3�3�D�#�>�>�>�>�>�	?�	?r+c��|jrJ�|js|jjr|j�|||��|jr�t
|jt��sJ�	|jj	�
|||��|jj|jurd|j_d|_dS#|jj|jurd|j_d|_wxYwd|_dSr:)
rrrr�rollback_twophaserhr�rr�rr�r%r��r$r�is_prepareds   r)�_rollback_twophase_implz"Connection._rollback_twophase_implRs���%�%�%�%���	D�t�{�6�	D��M�+�+�D�#�{�C�C�C��3�	&��d�0�2E�F�F�F�F�F�
*���#�8�8��#�{�����?�/�4�3E�E�E�37�D�O�0�%)��"�"�"���?�/�4�3E�E�E�37�D�O�0�%)��"�)�)�)�)�!%�D�����!B&�&(Cc��|jrJ�|js|jjr|j�|||��|jr�t
|jt��sJ�	|jj	�
|||��|jj|jurd|j_d|_dS#|jj|jurd|j_d|_wxYwd|_dSr:)
rrrr�commit_twophaserhr�rr�rr�r%r�r�s   r)�_commit_twophase_implz Connection._commit_twophase_imples����%�%�%�%���	B�t�{�6�	B��M�)�)�$��[�A�A�A��3�		&��d�0�2E�F�F�F�F�F�
*���#�6�6�t�S�+�N�N�N��?�/�4�3E�E�E�37�D�O�0�%)��"�"�"���?�/�4�3E�E�E�37�D�O�0�%)��"�)�)�)�)�!%�D���r�c�n�|j���s|j���dSdSr:)r1r�r�r/s r)�
_autorollbackzConnection._autorollbackvs<���z�(�(�*�*�	(��J�%�%�'�'�'�'�'�	(�	(r+c��|jr,	|`n#t$rYnwxYwd|_dS#d|_YdSxYw	|j}|���|j|jurd|_|js|`n#t$rYnwxYwd|_d|_dS)afClose 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`.

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

        FN)rrrSr r?r�rr)r$�conns  r)r?zConnection.closezs���&��	�
��%�%��!�
�
�
���
����(-��$����(-��$��������	&��$�D�

�J�J�L�L�L�� �D�$6�6�6�$(��!�
�>�
&��%����	�	�	��D�	���� %���!����s-��%�
�%��%�	1�A/�/
A<�;A<c�H�|j|g|�Ri|�����S)z�Executes and returns the first column of the first row.

        The underlying result/cursor is closed after execution.
        ��execute�scalar)r$�object_�multiparams�paramss    r)r�zConnection.scalar�s2���t�|�G�<�k�<�<�<�V�<�<�C�C�E�E�Er+c��t|tjd��r|�|||��S	|j}||||��S#t
$r3}tjtj|��|���Yd}~dSd}~wwxYw)a�Executes a SQL statement construct and returns a
        :class:`_engine.ResultProxy`.

        :param object: The statement to be executed.  May be
         one of:

         * a plain string
         * any :class:`_expression.ClauseElement` construct that is also
           a subclass of :class:`.Executable`, such as a
           :func:`_expression.select` construct
         * a :class:`.FunctionElement`, such as that generated
           by :data:`.func`, will be automatically wrapped in
           a SELECT statement, which is then executed.
         * a :class:`.DDLElement` object
         * a :class:`.DefaultGenerator` object
         * a :class:`.Compiled` object

        :param \*multiparams/\**params: represent bound parameter
         values to be used in the execution.   Typically,
         the format is either a collection of one or more
         dictionaries passed to \*multiparams::

             conn.execute(
                 table.insert(),
                 {"id":1, "value":"v1"},
                 {"id":2, "value":"v2"}
             )

         ...or individual key/values interpreted by \**params::

             conn.execute(
                 table.insert(), id=1, value="v1"
             )

         In the case that a plain SQL string is passed, and the underlying
         DBAPI accepts positional bind parameters, a collection of tuples
         or individual values in \*multiparams may be passed::

             conn.execute(
                 "INSERT INTO table (id, value) VALUES (?, ?)",
                 (1, "v1"), (2, "v2")
             )

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

         Note above, the usage of a question mark "?" or other
         symbol is contingent upon the "paramstyle" accepted by the DBAPI
         in use, which may be any of "qmark", "named", "pyformat", "format",
         "numeric".   See `pep-249 <http://www.python.org/dev/peps/pep-0249/>`_
         for details on paramstyle.

         To execute a textual SQL statement which uses bound parameters in a
         DBAPI-agnostic way, use the :func:`_expression.text` construct.

        r)�replace_contextN)	r�r�string_types�
_execute_text�_execute_on_connectionrS�raise_r	�ObjectNotExecutableError)r$r�r�r��meth�errs      r)r�zConnection.execute�s���v�g�t�0��3�4�4�	D��%�%�g�{�F�C�C�C�	3��1�D��4��k�6�2�2�2���	�	�	��K��,�W�5�5�s�
�
�
�
�
�
�
�
�
�
�����	���s�A
�
B
�(B�B
c�T�|�|���||��S)z%Execute a sql.FunctionElement object.)�_execute_clauseelement�select)r$�funcr�r�s    r)�_execute_functionzConnection._execute_function�s$���*�*�4�;�;�=�=�+�v�N�N�Nr+c�@�|js|jjr!|jjD]}|||||��\}}}�		|j}n#t
$rd}YnwxYw|�|���}|j}|j�	|||��}n0#t$r#}|�|dddd��Yd}~nd}~wwxYw|�d|d��}	|j
r|���|js|jjr|j�|||||	��|	S)z&Execute a schema.ColumnDefault object.N)rrr�before_executerrSrTr�execution_ctx_cls�
_init_defaultrUrV�
_exec_defaultrr?�
after_execute)
r$�defaultr�r��fnr�r�ctxrX�rets
          r)�_execute_defaultzConnection._execute_default�s�����	�t�{�6�	��m�2�
�
��/1�r��'�;��0�0�,���f�f�
	D�
��(����!�
�
�
�����
�����|��2�2�4�4���l�G��+�9�9�'�4��N�N�C�C���	D�	D�	D��(�(��D�$��d�C�C�C�C�C�C�C�C�����	D��������g�t�4�4���(�	��J�J�L�L�L���	�t�{�6�	��M�'�'��g�{�F�C�
�
�
��
s2�?�B�A�B�
A�<B�
B8�B3�3B8c�x�|js|jjr!|jjD]}|||||��\}}}�|j}|�||jjs|jnd���}|�||j	j
|d|��}|js|jjr|j�|||||��|S)zExecute a schema.DDL object.N)r�schema_translate_map)rrrr�r�compiler�
is_default�_execute_contextr��	_init_ddlr�)r$�ddlr�r�r�r�compiledr�s        r)�_execute_ddlzConnection._execute_ddls�����	N�t�{�6�	N��m�2�
N�
N��+-�2�d�C��f�+M�+M�(��[�&�&��,���;�;���)�4�"��!7�!7��	�
�
���#�#���%�/����
�
����	M�t�{�6�	M��M�'�'��c�;���L�L�L��
r+c��|js|jjr!|jjD]}|||||��\}}}�t	||��}|r(t|d�����}ng}|j}d|jvr�||tt|����|jjt|��dkf}|jd�|��}	|	�M|�||t|��dk|jjs|jnd���}	|	|jd|<n=|�||t|��dk|jjs|jnd���}	|�||jj|	||	|��}
|js|jjr|j�|||||
��|
S)z#Execute a sql.ClauseElement object.r�compiled_cacherN)r�column_keys�inliner�)rrrr�r�list�keysrr�tuple�sortedr�hash_key�len�getr�r�r�r��_init_compiledr�)r$�elemr�r�r��distilled_paramsr�r�key�compiled_sqlr�s           r)r�z!Connection._execute_clauseelement7s����	P�t�{�6�	P��m�2�
P�
P��,.�B�t�T�;��,O�,O�)��k�6�6�*�;��?�?���	��(��+�0�0�2�2�3�3�D�D��D��,���t�6�6�6����f�T�l�l�#�#��&�/��$�%�%��)��C� �2�3C�D�H�H��M�M�L��#�#�|�|�#� $��/�0�0�1�4��1�<�*��)?�)?��
 ,� � ��BN��'�(8�9�#�>���<�<�� ��+�,�,�q�0��-�8�&�T�%;�%;��
(���L��#�#���%�4�����

�
����	N�t�{�6�	N��M�'�'��d�K���M�M�M��
r+c�F�|js|jjr!|jjD]}|||||��\}}}�|j}t||��}|�||jj||||��}|js|jjr|j�	|||||��|S)zExecute a sql.Compiled object.)
rrrr�rrr�r�r�r�)r$r�r�r�r�r�
parametersr�s        r)�_execute_compiledzConnection._execute_compiledps�����	�t�{�6�	��m�2�
�
��02���(�K��1�1�-��+�v�v��,��$�[�&�9�9�
��#�#���%�4�����

�
����	�t�{�6�	��M�'�'��h��V�S�
�
�
��
r+c�F�|js|jjr!|jjD]}|||||��\}}}�|j}t||��}|�||jj||||��}|js|jjr|j�	|||||��|S)zExecute a string SQL statement.)
rrrr�rrr�r��_init_statementr�)r$�	statementr�r�r�rrr�s        r)r�zConnection._execute_text�s�����	�t�{�6�	��m�2�
�
��13���)�[�&�2�2�.�	�;����,��$�[�&�9�9�
��#�#���%�5�����

�
����	�t�{�6�	��M�'�'��i��f�c�
�
�
��
r+c	�v�		|j}n#t$rd}YnwxYw|�|���}||||g|�R�}nB#t$r5}|�|tj|��|dd��Yd}~nd}~wwxYw|jr|���|j	|j
|j}}}	|js|d}|j
s|jj
r'|jjD]}
|
||	||||j��\}}�|jr�|jj�|��|jjs;|jj�dt+j|d|j�����n|jj�d��d}	|jrR|jj
r&|jjjD]}
|
|	|||��rd}n�|s|j�|	|||��n�|sW|jrP|jj
r%|jjjD]}
|
|	||��rd}n�|s|j�|	||��nQ|jj
r&|jjjD]}
|
|	|||��rd}n�|s|j�|	|||��|j
s|jj
r$|j�||	||||j��|jr|���|js|jr|� ��}n/|�!��}|j"�|�#��|j$r'|j%j&�|j%�'d�	��|j(r#|j)r|�*��nd|_+n0#t$r#}|�||||	|��Yd}~nd}~wwxYw|S)
zmCreate an :class:`.ExecutionContext` and execute, returning
        a :class:`_engine.ResultProxy`.

        Nr�%r�
)�batches�ismultiz3[SQL parameters hidden due to hide_parameters=True]FT)r�),rrSrTrUrVr�	text_typer��pre_exec�cursorr	r�executemanyrrr�before_cursor_executerr�rj�hide_parameters�sql_util�_repr_paramsr�do_executemany�
no_parameters�do_execute_no_params�
do_execute�after_cursor_execute�	post_exec�is_crud�is_text�_setup_crud_result_proxy�get_result_proxy�	_metadata�_soft_close�should_autocommitr1rr�r�_soft_closedr?�_autoclose_connection)
r$r�constructorr	r�argsr�r�rXrr��evt_handled�results
             r)r�zConnection._execute_context�s(��	�
��(����!�
�
�
�����
�����|��2�2�4�4��!�k�'�4��=��=�=�=�G�G���	�	�	��(�(��4�>�)�,�,�j�$��
�
�
�
�
�
�
�
�����	����
��	�������
�N�����&�	���"�	'�#�A��J���		�t�{�6�		��m�9�
�
��(*��������'�
)�)�%�	�:�:��:�	��K��#�#�I�.�.�.��;�.�

���"�'�'���)�"�B��8K����������"�'�'�I������F	��"�
��<�+�"�"�l�3�B�"�"���2�f�i��W�E�E�"�*.�K�!�E�"�#���L�/�/��	�:�w����� �
�G�$9�
��<�+�"�"�l�3�H�"�"���2�f�i��9�9�"�*.�K�!�E�"�#���L�5�5��	�7������<�+�"�"�l�3�>�"�"���2�f�i��W�E�E�"�*.�K�!�E�"�#���L�+�+��	�:�w������
�4�;�#:�
��
�2�2�������'�
�����
$��!�!�#�#�#���
)�'�/�
)� �9�9�;�;��� �1�1�3�3���#�+��&�&�(�(�(��(�
9�T�Z�-E�-M��
�'�'�4�'�8�8�8��,�
8��&�8��J�J�L�L�L�L�48�F�0����	�	�	��(�(��9�j�&�'�
�
�
�
�
�
�
�
�����	����
�
sB��?��?��$?�
A>�	+A9�9A>�	G?N	�	
N6�N1�1N6c	�f�|js|jjr"|jjD]}||||||d��\}}�|jr?|jj�|��|jj�d|��	|jjsdn|jjjD]}|||||��rn�|j�||||��n0#t$r#}|�
|||||��Yd}~nd}~wwxYw|js|jjr!|j�|||||d��dSdS)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().

        Frr;N)rrrrrr�rjrrrUrVr)r$rr	rr�r�rXs       r)�_cursor_executezConnection._cursor_execute*s�����	�t�{�6�	��m�9�
�
��(*���&�)�Z��%�)�)�%�	�:�:��:�	6��K��#�#�I�.�.�.��K��#�#�D�*�5�5�5�
	��|�/�6����\�*�5�
P�
P��
�2�f�i��W�=�=���E����'�'��	�:�w�O�O�O����	�	�	��(�(��9�j�&�'�
�
�
�
�
�
�
�
�����	����
��	�t�{�6�	��M�.�.��f�i��W�e�
�
�
�
�
�	�	s�=AC
�
C:�C5�5C:c��	|���dS#t$r*|jjj�dd���YdSwxYw)z\Close the given cursor, catching exceptions
        and turning into log warnings.

        zError closing cursorT)�exc_infoN)r?�	Exceptionr�poolr��error)r$rs  r)�_safe_close_cursorzConnection._safe_close_cursorRsl��
	��L�L�N�N�N�N�N���	�	�	��K��#�)�)�&��
*�
�
�
�
�
�
�	���s��0A�Ac��tj��}|r|j�||_t|t��}|jsnt||jjj��o1|j	o)|j�
||js|jnd|��p	|o|j	|_|r|j|_
|}|j
rhtjt j�||||jjj|jj|j|�|jnd���|d|���d|_
	t||jjj��p
|duo|duo|}	|	rTt j�||||jjj|jj|j|j|�|jnd���}
nd}
d}|js|jjr�|j�dd��s�|	r!|r|j�||||||��t7||
|j||||||j|�
�
}|jjD]3}
	|
|��}|�	|x|_}�#t$r
}|}Yd}~nd}~wwxYw|j|j
kr|j
|_|
r|j
|
_|j}|	r|r|� |��|jsX|r|�!|��tj"d���5|�#��ddd��n#1swxYwY|rtj||d|���nB|	rtj|
|d|���n"tj|d	|d�
��|`
|jrG|`|js>|j}|r |jj$�%||��|�&|��|j'r|�(��dSdS#|`
|jrG|`|js>|j}|r |jj$�%||��|�&|��|j'r|�(��wwxYw)N)rrrr��with_traceback�from_T)r�connection_invalidatedrr�skip_user_error_eventsF)�	warn_onlyr�r4))�sysr-rtr�r.�_is_disconnectr�dbapi�ErrorrO�
is_disconnectrQr�_reentrant_errorrr�r	�
DBAPIError�instancerrrrrr�r�dbapi_error�ExceptionContextImpl�handle_error�chained_exceptionr6�invalidate_pool_on_disconnect�handle_dbapi_exceptionr1�safe_reraiser�r/�_invalidatersrr?)r$rXr	rrr�r-�is_exit_exceptionrF�should_wrap�sqlalchemy_exception�newraiser�r��per_fn�_raised�dbapi_conn_wrappers                 r)rVz"Connection._handle_dbapi_exceptionbs����<�>�>���	"�w�(�0� !�G�� *�1�i� 8� 8�8���"�	<��1�d�l�0�6�7�7����O���L�.�.��-1�-=�G�D�%�%�4����#9�$�7�D�K��
���
<�(,�(;��%�,=�(=�%�� �	��K���'�'�����L�&�,�$(�K�$?� �L��*�$�/�/��(�
�
� (��{��
�
�
�
�!%���i	�%�Q���(:�(@�A�A����%�*��t�O�*�)�)�
��
,�'*�~�'>�'>�����L�&�,�$(�K�$?�+/�+>� �L��*�$�/�/��(?�(�(�$�$�(,�$��H�� �0
�$(�K�$;�0
��-�1�1�(�%���0
���7���M�-�-��f�i��W�a����
+��(��K�������'�1�����-�4�
�
�B�	�"$��C����!�-�?E�E�C�1�H���$����#*����������������
�&�#�*;�;�;�*-�*;�D�'�+���-�-�C��5�.��
2�w�
2��.�.�q�1�1�1��&�
)��4��+�+�F�3�3�3��&��6�6�6�)�)��&�&�(�(�(�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)��
E���H�X�a�[��J�J�J�J�J��
E���(��!��A��������H�Q�K����D�D�D�D��%��"�
'��'��'�'�)-�):�&�4�L���(�4�4�5G��K�K�K��O�O�A�&�&�&��,�
��
�
������
�
���%��"�
'��'��'�'�)-�):�&�4�L���(�4�4�5G��K�K�K��O�O�A�&�&�&��,�
��
�
�����
���s^�)DO�/I�O�
I�I�O�I�BO�K>�2O�>L�O�L�A%O�A.Qc��tj��}|�|dd��}t||jj��}|r5tj�dd||jj|j	|���}nd}d}|j
rst|||ddddd|d�
�
}	|jj
D]3}
	|
|	��}|�	|x|	_}�#t$r
}|}Yd}~nd}~wwxYw|r||	jkr|	jx|_}|rt#j||d|���dS|rt#j||d|���dSt#j|d|d���dS)N)rr6Trr3rr9)r:r-r>r�r<r=r	r@rArrrCrrDrEr.r6rr�)
�clsrXrrr-r>rKrLrMr�r�rNrOs
             r)�$_handle_dbapi_exception_noconnectionz/Connection._handle_dbapi_exception_noconnection�s����<�>�>���-�-�a��t�<�<�
� ��G�M�$7�8�8���
	(�#&�>�#:�#:�����
�#� &� 6�'4�
$;�$�$� � �$(� �����	&�&��$�����������C��o�2�

�

��	� �R��W�W�F��)�;A�A��-���� ����&�H��E�E�E�E�E���������
$�
&�
��9J�(J�(J��%�&�$�;�!��	A��K���!��A�F�F�F�F�F�F�
�	A��K�$�X�a�[��
�
�
�
�
�
�
�K����H�Q�K�@�@�@�@�@�@s�.C�
C�C�Cc��|���}	|j|g|�Ri|��}|���|S#tj��5|���ddd��YdS#1swxYwYYdSxYw)abExecute the given function within a transaction boundary.

        The function is passed this :class:`_engine.Connection`
        as the first argument, followed by the given \*args and \**kwargs,
        e.g.::

            def do_something(conn, x, y):
                conn.execute("some statement", {'x':x, 'y':y})

            conn.transaction(do_something, 5, 10)

        The operations inside the function are all invoked within the
        context of a single :class:`.Transaction`.
        Upon success, the transaction is committed.  If an
        exception is raised, the transaction is rolled back
        before propagating the exception.

        .. note::

           The :meth:`.transaction` method is superseded by
           the usage of the Python ``with:`` statement, which can
           be used with :meth:`_engine.Connection.begin`::

               with conn.begin():
                   conn.execute("some statement", {'x':5, 'y':10})

           As well as with :meth:`_engine.Engine.begin`::

               with engine.begin() as conn:
                   conn.execute("some statement", {'x':5, 'y':10})

        .. seealso::

            :meth:`_engine.Engine.begin` - engine-level transactional
            context

            :meth:`_engine.Engine.transaction` - engine-level version of
            :meth:`_engine.Connection.transaction`

        N)rx�run_callabler�rrHr�)r$�	callable_r'rpr�r�s      r)r�zConnection.transaction5s���T�
�
����	!�#�$�#�I�?��?�?�?��?�?�C��L�L�N�N�N��J��	!��"�$�$�
!�
!���� � � �
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!�
!�
!�
!���s-�&=�B�A5�'B�5A9	�9B�<A9	�=Bc��||g|�Ri|��S)a�Given a callable object or function, execute it, passing
        a :class:`_engine.Connection` as the first argument.

        The given \*args and \**kwargs are passed subsequent
        to the :class:`_engine.Connection` argument.

        This function, along with :meth:`_engine.Engine.run_callable`,
        allows a function to be run with a :class:`_engine.Connection`
        or :class:`_engine.Engine` object without the need to know
        which one is being dealt with.

        r;)r$rVr'rps    r)rUzConnection.run_callablehs$���y��/��/�/�/��/�/�/r+c�J�||j|fi|���|��dSr:)r�traverse_single)r$�visitorcallable�elementrps    r)�_run_visitorzConnection._run_visitorws2������d�5�5�f�5�5�E�E�g�N�N�N�N�Nr+)NFNNNNr:�F)D�__name__�
__module__�__qualname__�__doc__r
�_schema_getterrr*r-�propertyr1r8r<rDrIrLrOrQr%rZr\rTrfrhrjrmrqrsrvrxr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r?r�r�r�r�r�r�rr�r�r+r1r?r;rV�classmethodrSr�rUr\r;r+r)rrs���������2.��-�d�3�3��
�$������8>�8>�8>�8>�t���8����X�����������a�a�a�F	'�	'�	'��
�
��X�
��$�$��X�$�
�D�D��X�D�*#D�#D�#D�J�4�4��X�4�@C�C�C��=�=��X�=��
�
��X�
��$�$��X�$�
�
�
����2$�2$�2$�2$�h#�#�#�8*9�*9�*9�X"�"�"�6"�"�"�"�B=�=�=�M�M�M�M�K�K�K�K�4�4�4�D�D�D� &�&�&�.&�&�&�&�(����	6�	6�	6�%�%�%�%�%�%�;�;�;�?�?�?�&�&�&�&&�&�&�"(�(�(�+"�+"�+"�ZF�F�F�D3�D3�D3�LO�O�O�
!�!�!�F���47�7�7�r���2���2F�F�F�P&�&�&�&�P������N�T�T�T�l�:A�:A��[�:A�x1!�1!�1!�f
0�
0�
0�O�O�O�O�Or+rc��eZdZdZd�ZdS)rCz3Implement the :class:`.ExceptionContext` interface.c��||_||_||_||_||_||_||_|	|_|
|_dSr:)	rr%rL�original_exception�execution_contextr	rr>rF)r$rtrLrr%rr	rr�r>rFs           r)r*zExceptionContextImpl.__init__~sN�����$���$8��!�"+���!(���"���$���*���-J��*�*�*r+N)r^r_r`rar*r;r+r)rCrC{s.������=�=�K�K�K�K�Kr+rCc�X�eZdZdZd�Zed���Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dS)rzahRepresent 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://scott:tiger@localhost/test")
        connection = engine.connect()
        trans = connection.begin()
        connection.execute("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("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
    c�0�||_||_d|_dS)NT)r%�_actual_parent�	is_active)r$r%�parents   r)r*zTransaction.__init__�s��$���$�������r+c��|jp|Sr:)rkr/s r)r�zTransaction._parent�s���"�*�d�*r+c��|jjr|j|ur|���|j�|��dS)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)r�rlr�r%r�r/s r)r?zTransaction.close�sF���<�!�	�d�l�d�&:�&:��M�M�O�O�O���,�,�T�2�2�2�2�2r+c�X�|jjr|���d|_dSdS)z%Roll back this :class:`.Transaction`.FN)r�rl�_do_rollbackr/s r)r�zTransaction.rollback�s6���<�!�	#�������"�D�N�N�N�	#�	#r+c�8�|j���dSr:)r�r�r/s r)rqzTransaction._do_rollback�s����������r+c�|�|jjstjd���|���d|_dS)z"Commit this :class:`.Transaction`.�This transaction is inactiveFN)r�rlr	r`�
_do_commitr/s r)r�zTransaction.commit�s?���|�%�	J��)�*H�I�I�I�����������r+c��dSr:r;r/s r)ruzTransaction._do_commit�s���r+c��|Sr:r;r/s r)r<zTransaction.__enter__�r=r+c��|�h|jra	|���dS#tj��5|���ddd��n#1swxYwYYdSYdSxYw|���dSr:)rlr�rrHr�r@s    r)rDzTransaction.__exit__�s����=�T�^�=�
$����
�
�
�
�
��
$��&�(�(�$�$��M�M�O�O�O�$�$�$�$�$�$�$�$�$�$�$����$�$�$�$�$�$�$�$�$�$����
�M�M�O�O�O�O�Os,�!�A(�A�A(�A	�A(�A	�A(N)r^r_r`rar*rcr�r?r�rqr�rur<rDr;r+r)rzrz�s�������"�"�H���
�+�+��X�+�3�3�3� #�#�#� � � ����
�
�
��������r+rzc�*��eZdZ�fd�Zd�Zd�Z�xZS)ryc���tt|���|d��|j�|��dSr:)�superryr*r%r�)r$r%r3s  �r)r*zRootTransaction.__init__�s?���
�o�t�$�$�-�-�j�$�?�?�?���#�#�D�)�)�)�)�)r+c�J�|jr|j���dSdSr:)rlr%r�r/s r)rqzRootTransaction._do_rollback�s0���>�	-��O�*�*�,�,�,�,�,�	-�	-r+c�J�|jr|j���dSdSr:)rlr%r�r/s r)ruzRootTransaction._do_commit�s0���>�	+��O�(�(�*�*�*�*�*�	+�	+r+)r^r_r`r*rqru�
__classcell__�r3s@r)ryry�sV�������*�*�*�*�*�-�-�-�+�+�+�+�+�+�+r+ryc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)r}z�Represent a 'nested', or SAVEPOINT transaction.

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

    The interface is the same as that of :class:`.Transaction`.

    c���tt|���||��|j���|_dSr:)r{r}r*r%r��
_savepoint)r$r%rmr3s   �r)r*zNestedTransaction.__init__s=���
���&�&�/�/�
�F�C�C�C��/�9�9�;�;����r+c�b�|jr'|j�|j|j��dSdSr:)rlr%r�r�r�r/s r)rqzNestedTransaction._do_rollbacksC���>�	��O�7�7�����
�
�
�
�
�	�	r+c�b�|jr'|j�|j|j��dSdSr:)rlr%r�r�r�r/s r)ruzNestedTransaction._do_commitsC���>�	��O�3�3�����
�
�
�
�
�	�	r+)r^r_r`rar*rqrur~rs@r)r}r}s`���������<�<�<�<�<����������r+r}c�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)r�aRepresent 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.

    c���tt|���|d��d|_||_|j�|��dS)NF)r{r�r*�_is_preparedrr%r�)r$r%rr3s   �r)r*zTwoPhaseTransaction.__init__*sO���
�!�4�(�(�1�1�*�d�C�C�C�!��������,�,�T�2�2�2�2�2r+c��|jjstjd���|j�|j��d|_dS)zqPrepare this :class:`.TwoPhaseTransaction`.

        After a PREPARE, the transaction can be committed.

        rtTN)r�rlr	r`r%r�rr�r/s r)�preparezTwoPhaseTransaction.prepare0sJ���|�%�	J��)�*H�I�I�I���.�.�t�x�8�8�8� ����r+c�P�|j�|j|j��dSr:)r%r�rr�r/s r)rqz TwoPhaseTransaction._do_rollback;s%����/�/���$�:K�L�L�L�L�Lr+c�P�|j�|j|j��dSr:)r%r�rr�r/s r)ruzTwoPhaseTransaction._do_commit>s%����-�-�d�h��8I�J�J�J�J�Jr+)	r^r_r`rar*r�rqrur~rs@r)r�r�sy���������3�3�3�3�3�	!�	!�	!�M�M�M�K�K�K�K�K�K�Kr+r�c���eZdZdZej��ZdZeZ	e
jd��Z						d"d�Z
ed���Zd�Zd�Zd�Zed	���Zed
���Zej��Zd�Zd�Zd
�Zejd#d���Z	d#d�ZGd�de��Z d$d�Z!d�Z"d�Z#d�Z$d�Z%d%d�Z&d�Z'd�Z(ej)dd��d$d���Z*d$d�Z+d%d�Z,d#d�Z-d �Z.d#d!�Z/dS)&�Enginea�
    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`

    FNc	���||_||_||_|r||_||_||_t
j||���|r tj	�
||��|r|jdi|��dSdS�N)�echoflagr;)r/�urlr�logging_name�echorr�instance_loggerr
�ConnectionProxy�_adapt_listener�update_execution_options)	r$r/rr�r�r��proxyrIrs	         r)r*zEngine.__init__gs�����	��������	-� ,�D����	�.�����D�4�0�0�0�0��	D��&�6�6�t�U�C�C�C��	?�)�D�)�>�>�,=�>�>�>�>�>�	?�	?r+c��|Sr:r;r/s r)rz
Engine.engines���r+c��|j�|��|_|j�||��|j�||��dS)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)rrFr�set_engine_execution_optionsr�r$rHs  r)r�zEngine.update_execution_options�sS��"#'�"9�"?�"?��"D�"D����
�2�2�4��=�=�=���1�1�$��<�<�<�<�<r+c�"�t||��S)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 "sharding" schemes where multiple :class:`_engine.Engine`
        objects refer to the same connection pool, but are differentiated
        by options that would be consumed by a custom event::

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

        Above, the ``shard1`` engine serves as a factory for
        :class:`_engine.Connection`
        objects that will contain the execution option
        ``shard_id=shard1``, and ``shard2`` will produce
        :class:`_engine.Connection`
        objects that contain the execution option ``shard_id=shard2``.

        An event handler can consume the above execution option to perform
        a schema switch or other operation, given a connection.  Below
        we emit a MySQL ``use`` statement to switch databases, at the same
        time keeping track of which database we've established using the
        :attr:`_engine.Connection.info` dictionary,
        which gives us a persistent
        storage space that follows the DBAPI connection::

            from sqlalchemy import event
            from sqlalchemy.engine import Engine

            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._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

        .. 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`


        )�OptionEnginer�s  r)rIzEngine.execution_options�s��T�D�#�&�&�&r+c��|jS)z�Get the non-SQL options which will take effect during execution.

        .. versionadded: 1.3

        .. seealso::

            :meth:`_engine.Engine.execution_options`
        rKr/s r)rLzEngine.get_execution_options�rMr+c��|jjS)ziString name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
        in use by this :class:`Engine`.)rr�r/s r)r�zEngine.name�s��
�|� � r+c��|jjS)ziDriver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
        in use by this :class:`Engine`.)r�driverr/s r)r�z
Engine.driver�s��
�|�"�"r+c��d|jzS)Nz
Engine(%r))r�r/s r)�__repr__zEngine.__repr__�s���d�h�&�&r+c��|j���|j���|_|j�|��dS)a�Dispose of the connection pool used by this
        :class:`_engine.Engine`.

        This 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.

        A new connection pool is created immediately after the old one has
        been disposed.   This new pool, like all SQLAlchemy connection pools,
        does not make any actual connections to the database until one is
        first requested, so as long as the :class:`_engine.Engine`
        isn't used again,
        no new connections will be made.

        .. seealso::

            :ref:`engine_disposal`

        N)r/�dispose�recreater�engine_disposedr/s r)r�zEngine.disposesI��2	
�	�������I�&�&�(�(��	��
�%�%�d�+�+�+�+�+r+c��|���5}|�|di��cddd��S#1swxYwYdS)Nr;)rqr�)r$r�r�s   r)r�zEngine._execute_defaults���
�
%�
%�
'�
'�	:�4��(�(��"�b�9�9�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:�	:����	:�	:�	:�	:�	:�	:s
�9�=�=c#�|K�|�3|���5}|V�ddd��dS#1swxYwYdS|V�dSr:�rq)r$r%r�s   r)�_optional_conn_ctx_managerz!Engine._optional_conn_ctx_manager#s��������)�)�+�+�
�t��
�
�
�
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
������s�+�/�/c��|�|��5}|j||fi|��ddd��dS#1swxYwYdSr:)r�r\)r$rZr[r%rpr�s      r)r\zEngine._run_visitor+s����
,�
,�Z�
8�
8�	B�D��D��o�w�A�A�&�A�A�A�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B�	B����	B�	B�	B�	B�	B�	Bs�3�7�7c� �eZdZd�Zd�Zd�ZdS)�Engine._trans_ctxc�0�||_||_||_dSr:)r�r�r&)r$r�r�r&s    r)r*zEngine._trans_ctx.__init__2s���D�I�*�D��%6�D�"�"�"r+c��|jSr:)r�r/s r)r<zEngine._trans_ctx.__enter__7s
���9�r+c��|�|j���n|j���|js|j���dSdSr:)r�r�r�r&r�r?r@s    r)rDzEngine._trans_ctx.__exit__:sb��� �� �)�)�+�+�+�+�� �'�'�)�)�)��)�
"��	���!�!�!�!�!�
"�
"r+N)r^r_r`r*r<rDr;r+r)�
_trans_ctxr�1sA������	7�	7�	7�
	�	�	�	"�	"�	"�	"�	"r+r�c��|�|���}	|���}nF#tj��5|���ddd��n#1swxYwYYnxYwt
�|||��S)aReturn a context manager delivering a :class:`_engine.Connection`
        with a :class:`.Transaction` established.

        E.g.::

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

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

        The ``close_with_result`` flag is normally ``False``, and indicates
        that the :class:`_engine.Connection` will be closed when the operation
        is complete.   When set to ``True``, it indicates the
        :class:`_engine.Connection` is in "single use" mode, where the
        :class:`_engine.ResultProxy` returned by the first call to
        :meth:`_engine.Connection.execute` will close the
        :class:`_engine.Connection` when
        that :class:`_engine.ResultProxy` has exhausted all result rows.

        .. 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`.

        �r&N)rqrxrrHr?r�r�)r$r&r�r�s    r)rxzEngine.beginBs���B�'�'�:K�'�L�L��	��J�J�L�L�E�E��	��"�$�$�
�
��
�
����
�
�
�
�
�
�
�
�
�
�
����
�
�
�
������� � ��u�.?�@�@�@s-�-�A0�A#�A0�#A'	�'A0�*A'	�+A0c��|���5}|j|g|�Ri|��cddd��S#1swxYwYdS)aExecute the given function within a transaction boundary.

        The function is passed a :class:`_engine.Connection` newly procured
        from :meth:`_engine.Engine.contextual_connect` as the first argument,
        followed by the given \*args and \**kwargs.

        e.g.::

            def do_something(conn, x, y):
                conn.execute("some statement", {'x':x, 'y':y})

            engine.transaction(do_something, 5, 10)

        The operations inside the function are all invoked within the
        context of a single :class:`.Transaction`.
        Upon success, the transaction is committed.  If an
        exception is raised, the transaction is rolled back
        before propagating the exception.

        .. note::

           The :meth:`.transaction` method is superseded by
           the usage of the Python ``with:`` statement, which can
           be used with :meth:`_engine.Engine.begin`::

               with engine.begin() as conn:
                   conn.execute("some statement", {'x':5, 'y':10})

        .. seealso::

            :meth:`_engine.Engine.begin` - engine-level transactional
            context

            :meth:`_engine.Connection.transaction`
            - connection-level version of
            :meth:`_engine.Engine.transaction`

        N)rqr��r$rVr'rpr�s     r)r�zEngine.transactionks���P�
%�
%�
'�
'�	@�4�#�4�#�I�?��?�?�?��?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@��3�7�7c��|���5}|j|g|�Ri|��cddd��S#1swxYwYdS)a�Given a callable object or function, execute it, passing
        a :class:`_engine.Connection` as the first argument.

        The given \*args and \**kwargs are passed subsequent
        to the :class:`_engine.Connection` argument.

        This function, along with :meth:`_engine.Connection.run_callable`,
        allows a function to be run with a :class:`_engine.Connection`
        or :class:`_engine.Engine` object without the need to know
        which one is being dealt with.

        N)rqrUr�s     r)rUzEngine.run_callable�s����
%�
%�
'�
'�	A�4�$�4�$�Y�@��@�@�@��@�@�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A�	A����	A�	A�	A�	A�	A�	Ar�c�P�|�d���}|j|g|�Ri|��S)a�Executes the given construct and returns a
        :class:`_engine.ResultProxy`.

        The arguments are the same as those used by
        :meth:`_engine.Connection.execute`.

        Here, a :class:`_engine.Connection` is acquired using the
        :meth:`_engine.Engine.contextual_connect` method,
        and the statement executed
        with that connection. The returned :class:`_engine.ResultProxy`
        is flagged
        such that when the :class:`_engine.ResultProxy` is exhausted and its
        underlying cursor is closed, the :class:`_engine.Connection`
        created here
        will also be closed, which allows its associated DBAPI connection
        resource to be returned to the connection pool.

        Tr�)rqr�)r$r	r�r�r%s     r)r�zEngine.execute�s=��(�-�-��-�E�E�
�!�z�!�)�D�k�D�D�D�V�D�D�Dr+c�H�|j|g|�Ri|�����Sr:r�)r$r	r�r�s    r)r�z
Engine.scalar�s0���t�|�I�>��>�>�>�v�>�>�E�E�G�G�Gr+c�\�|�d���}|�|||��S�NTr�)rqr�)r$rr�r�r%s     r)r�zEngine._execute_clauseelement�s0���-�-��-�E�E�
��0�0��{�F�K�K�Kr+c�\�|�d���}|�|||��Sr�)rqr)r$r�r�r�r%s     r)rzEngine._execute_compiled�s0���-�-��-�E�E�
��+�+�H�k�6�J�J�Jr+c��|j|fi|��S)a�Return a new :class:`_engine.Connection` object.

        The :class:`_engine.Connection` object is a facade that uses a DBAPI
        connection internally in order to communicate with the database.  This
        connection is procured from the connection-holding :class:`_pool.Pool`
        referenced by this :class:`_engine.Engine`. When the
        :meth:`_engine.Connection.close` method of the
        :class:`_engine.Connection` object
        is called, the underlying DBAPI connection is then returned to the
        connection pool, where it may be used again in a subsequent call to
        :meth:`_engine.Engine.connect`.

        )r.ros  r)rmzEngine.connect�s��$�t�#�D�3�3�F�3�3�3r+z1.3aThe :meth:`_engine.Engine.contextual_connect` method is deprecated. This method is an artifact of the threadlocal engine strategy which is also to be deprecated.   For explicit connections from an :class:`_engine.Engine`, use the :meth:`_engine.Engine.connect` method.c� �|jdd|i|��S)a�Return a :class:`_engine.Connection`
        object which may be part of some
        ongoing context.

        By default, this method does the same thing as
        :meth:`_engine.Engine.connect`.
        Subclasses of :class:`_engine.Engine` may override this method
        to provide contextual behavior.

        :param close_with_result: When True, the first
          :class:`_engine.ResultProxy`
          created by the :class:`_engine.Connection` will call the
          :meth:`_engine.Connection.close`
          method of that connection as soon as any
          pending result rows are exhausted. This is used to supply the
          "connectionless execution" behavior provided by the
          :meth:`_engine.Engine.execute` method.

        r&r;r��r$r&rps   r)�contextual_connectzEngine.contextual_connect�s0��<(�t�'�
�
�/�
�39�
�
�	
r+c�`�|j||�|jjd��fd|i|��S)Nr&)r.�_wrap_pool_connectr/rmr�s   r)rqzEngine._contextual_connect�sM��#�t�#���#�#�D�I�$5�t�<�<�
�
�0�
��	
�
�	
r+c��|�|��5}|j�||��cddd��S#1swxYwYdS)aReturn a list of all table names available in the database.

        :param schema: Optional, retrieve names from a non-default schema.

        :param connection: Optional, use a specified connection. Default is
          the ``contextual_connect`` for this ``Engine``.
        N)r�r�get_table_names)r$r
r%r�s    r)�table_nameszEngine.table_names	s����
,�
,�Z�
8�
8�	>�D��<�/�/��f�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�	>�	>s�>�A�Ac�D�|�|jj||��S)a`Return True if the given backend has a table of the given name.

        .. seealso::

            :ref:`metadata_reflection_inspector` - detailed schema inspection
            using the :class:`_reflection.Inspector` interface.

            :class:`.quoted_name` - used to pass quoting information along
            with a schema identifier.

        )rUr�	has_table)r$�
table_namer
s   r)r�zEngine.has_table	s!��� � ���!7��V�L�L�Lr+c�2�|j}	|��S#|jj$rt}|�t�|||��nJtjtj��dtj��d���Yd}~dSYd}~dSd}~wwxYw)Nrrr9)	rr<r=rrSrr�r:r-)r$r�r%rrXs     r)r�zEngine._wrap_pool_connect	s����,��
	��2�4�4�K���}�"�	�	�	��!��?�?��w���������L�N�N�1�%�c�l�n�n�Q�6G�����������	����������	���s�	�B�A#B�Bc�B�|�|jj|��S)aCReturn 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/�unique_connection)r$r^s  r)rzEngine.raw_connection+	s&��,�&�&��I�'��
�
�	
r+)NNNNFr:r])NN)0r^r_r`rar�
immutabledictrrrr.r
rbrr*rcrr�rIrLr�r�r�
echo_propertyr�r�r�r��
contextlib�contextmanagerr�r\�objectr�rxr�rUr�r�r�rrm�
deprecatedr�rqr�r�r�rr;r+r)r�r�Bs��������� ,��+�-�-���K� �O�-��-�d�3�3��
�(�
����?�?�?�?�0����X��=�=�=�*J'�J'�J'�X	'�	'�	'��!�!��X�!��#�#��X�#��3����D�'�'�'�,�,�,�::�:�:���������48�B�B�B�B�"�"�"�"�"�V�"�"�"�"'A�'A�'A�'A�R)@�)@�)@�VA�A�A� E�E�E�.H�H�H�L�L�L�L�K�K�K�4�4�4�"�T�_�
�	���
�
�
���
�2
�
�
�
�
>�
>�
>�
>�M�M�M�M����
�
�
�
�
�
r+r�c�`�eZdZdZd�Zd�Zd�Zeee��Zd�Z	d�Z
ee	e
��ZdS)r�Fc�<�||_|j|_|j|_|j|_|j|_|j|_t
j||j���|j�	|j��|_|j
|_
|jdi|��dSr�)�_proxiedr�rr�r�rrr�rr"rr�)r$�proxiedrIs   r)r*zOptionEngine.__init__I	s�����
��;�������#�0����L��	�&�6�����D�4�9�5�5�5�5��
�+�+�G�,<�=�=��
�")�"<���%��%�:�:�(9�:�:�:�:�:r+c��|jjSr:�r�r/r/s r)�	_get_poolzOptionEngine._get_poolc	s
���}�!�!r+c��||j_dSr:r�)r$r/s  r)�	_set_poolzOptionEngine._set_poolf	s��!��
���r+c�P�|jjp|j�dd��S)NrF)r�rr5r�r/s r)�_get_has_eventszOptionEngine._get_has_eventsk	s-���}�(�
�D�M�,=�,=��5�-
�-
�	
r+c��||jd<dS)Nr)r5)r$rBs  r)�_set_has_eventszOptionEngine._set_has_eventsp	s��',��
�m�$�$�$r+N)r^r_r`�_sa_propagate_class_eventsr*r�r�rcr/r�r�rr;r+r)r�r�F	s�������!&��;�;�;�4"�"�"�"�"�"��8�I�y�)�)�D�
�
�
�
-�-�-��(�?�O�<�<�K�K�Kr+r�)�
__future__rr�r:r
rrrr�r	r�sqlr
rrrCr�rzryr}r��
Identifiedr�r�r;r+r)�<module>r�sh��&�%�%�%�%�%�����
�
�
�
�#�#�#�#�#�#�(�(�(�(�(�(�!�!�!�!�!�!�������������������������������"�"�"�"�"�"��
\O�\O�\O�\O�\O��\O�\O�\O�~2K�K�K�K�K�+�K�K�K�6]�]�]�]�]�&�]�]�]�@+�+�+�+�+�k�+�+�+����������6 K� K� K� K� K�+� K� K� K�FA
�A
�A
�A
�A
�[�#�.�A
�A
�A
�H-=�-=�-=�-=�-=�6�-=�-=�-=�-=�-=r+

Hacked By AnonymousFox1.0, Coded By AnonymousFox