o znhJK@sddlmZddlZddlZddlmZddlmZddlmZddl m Z dd l mZdd l m Z dd l mZdd l m Z dd l mZ Gd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddee jZGdddeZdS))with_statementN) Connectable)ExceptionContext)_distill_params)exc) interfaces)log)util)schemac@s$eZdZdZedZ      dtddZddZe dd Z d d Z d d Z ddZ ddZddZe ddZe ddZe ddZddZe ddZddZe d d!Ze d"d#Ze d$d%Zd&d'Zd(d)Zdud*d+Zd,d-Zd.d/Zd0d1Zdud2d3Zd4d5Z dvd6d7Z!dvd8d9Z"d:d;Z#dd?Z%dvd@dAZ&dudBdCZ'dDdEZ(dFdGZ)dHdIZ*dJdKZ+dLdMZ,dNdOZ-dPdQZ.dRdSZ/dTdUZ0dVdWZ1dXdYZ2dZd[Z3d\d]Z4d^d_Z5d`daZ6dbdcZ7dddeZ8dudfdgZ9dhdiZ:dZ;dZdldmZ?dndoZ@dpdqZAdrdsZBdS)w Connectiona:Provides high-level functionality for a wrapped DB-API connection. Provides execution support for string-based SQL statements as well as :class:`.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 NFcCs||_|j|_||_|du|_|r*||_||_|j|_d|_||_|j |_ |j |_ n>|dur0|n| |_d|_ d|_ ||_d|_d|_|j|_|durV|j|j|_|p^|duo^|j |_ |rdJ|j|_|j so|jj ry|j||jdSdS)zConstruct a new Connection. The constructor here is not public and is only called only by an :class:`.Engine`. See :meth:`.Engine.connect` and :meth:`.Engine.contextual_connect` methods. NFrT)enginedialect_Connection__branch_from_Connection__branch_Connection__connection_execution_options_echoshould_close_with_resultdispatch _has_eventsschema_for_objectraw_connection_Connection__transaction_Connection__savepoint_seq_Connection__invalid_Connection__can_reconnect_should_log_info_joinengine_connect)selfr connectionclose_with_result _branch_fromr _dispatchrr&A/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/base.py__init__Es@    zConnection.__init__cCs2|jr|jS|jj|j|j||j|j|jdS)aReturn 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_clsrrrrr!r&r&r'r)s zConnection._branchcCs|jr|jS|S)zreturn the 'root' connection. Returns 'self' if this connection is not a branch, else returns the root connection from which we ultimately branched. )rr+r&r&r'_roots zConnection._rootcCs|j|j}|j|_|S)z3Create a shallow copy of this Connection. ) __class____new____dict__copy)r!cr&r&r'_clones zConnection._clonecC|SNr&r+r&r&r' __enter__zConnection.__enter__cCs |dSr4)closer!type_value tracebackr&r&r'__exit__ zConnection.__exit__cKsD|}|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:`.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:`.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:`.Connection.execution_options`, and it will be stored in the ``_execution_options`` dictionary of the :class:`.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:`.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 DBAPI connections by default are always in a transaction - SQLAlchemy uses rules applied to different kinds of statements to determine if COMMIT will be invoked in order to provide its "autocommit" feature. Typically, all INSERT/UPDATE/DELETE statements as well as CREATE/DROP statements have autocommit behavior enabled; SELECT constructs do not. Use this option when invoking a SELECT or other specific SQL construct where COMMIT is desired (typically when calling stored procedures and such), and an explicit transaction is not in progress. :param compiled_cache: Available on: Connection. A dictionary where :class:`.Compiled` objects will be cached when the :class:`.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:`.Connection`. Set the transaction isolation level for the lifespan of this :class:`.Connection` object. Valid values include those string values accepted by the :paramref:`.create_engine.isolation_level` parameter passed to :func:`.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:`.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:`.Connection.close` method on the original :class:`.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:`.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:`.Connection` is invalidated, e.g. via the :meth:`.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:`.create_engine.isolation_level` - set per :class:`.Engine` isolation level :meth:`.Connection.get_isolation_level` - view current level :ref:`SQLite Transaction Isolation ` :ref:`PostgreSQL Transaction Isolation ` :ref:`MySQL Transaction Isolation ` :ref:`SQL Server Transaction Isolation ` :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:`.Table.schema` element of each :class:`.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.execution_options` :meth:`.Executable.execution_options` :meth:`.Connection.get_execution_options` )r2runionrrr set_connection_execution_optionsr)r!optr1r&r&r'execution_optionsszConnection.execution_optionscC|jS)z Get the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`.Connection.execution_options` rr+r&r&r'get_execution_optionsR z Connection.get_execution_optionscCsd|jvo|j S)z)Return True if this connection is closed.r)r/rr+r&r&r'closed]s zConnection.closedcC|jjS)z/Return True if this connection was invalidated.)r,rr+r&r&r' invalidatedfszConnection.invalidatedc Cs`z|jWSty Ynwz|WSty/}z||ddddWYd}~dSd}~ww)zThe underlying DB-API connection managed by this Connection. .. seealso:: :ref:`dbapi_connections` N)rAttributeError_revalidate_connection BaseException_handle_dbapi_exceptionr!er&r&r'r"ls    zConnection.connectionc CsJz|j|jWSty$}z||ddddWYd}~dSd}~ww)aReturn the current isolation level assigned to this :class:`.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:`.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:`.Connection.default_isolation_level` accessor which returns the dialect-level setting without performing a SQL query. .. versionadded:: 0.9.9 .. seealso:: :attr:`.Connection.default_isolation_level` - view default level :paramref:`.create_engine.isolation_level` - set per :class:`.Engine` isolation level :paramref:`.Connection.execution_options.isolation_level` - set per :class:`.Connection` isolation level N)rget_isolation_levelr"rKrLrMr&r&r'rOs  zConnection.get_isolation_levelcCrG)aThe default isolation level assigned to this :class:`.Connection`. This is the isolation level setting that the :class:`.Connection` has when first procured via the :meth:`.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:`.Connection` basis. Unlike :meth:`.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:`.Connection.get_isolation_level` - view current level :paramref:`.create_engine.isolation_level` - set per :class:`.Engine` isolation level :paramref:`.Connection.execution_options.isolation_level` - set per :class:`.Connection` isolation level )rdefault_isolation_levelr+r&r&r'rPsz"Connection.default_isolation_levelcCsV|jr|jS|jr&|jr&|jdurtd|jj|d|_ d|_|j St d)Nz8Can't reconnect until invalid transaction is rolled back) _connectionFThis Connection is closed) rrJrrrrInvalidRequestErrorrrrResourceClosedErrorr+r&r&r'rJs    z!Connection._revalidate_connectioncCst|jddSNis_validF)getattrrr+r&r&r'_connection_is_validszConnection._connection_is_validcCs|j o|j ot|jddSrU)rFrHrWrr+r&r&r'#_still_open_and_connection_is_valids  z.Connection._still_open_and_connection_is_validcCrG)aInfo dictionary associated with the underlying DBAPI connection referred to by this :class:`.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:`.Connection`. )r"infor+r&r&r'rZs zConnection.infocC|S)aiReturns a branched version of this :class:`.Connection`. The :meth:`.Connection.close` method on the returned :class:`.Connection` can be called and this :class:`.Connection` will remain open. This method provides usage symmetry with :meth:`.Engine.connect`, including for usage with context managers. r)r+r&r&r'connects zConnection.connectcKr[r4r\r!kwargsr&r&r'_contextual_connectzConnection._contextual_connectcCsB|jrdS|jr td|jjr|jj||j`d|j_dS)aInvalidate the underlying DBAPI connection associated with this :class:`.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:`.Connection.execute` method or similar), this :class:`.Connection` will attempt to procure a new DBAPI connection using the services of the :class:`.Pool` as a source of connectivity (e.g. a "reconnection"). If a transaction was in progress (e.g. the :meth:`.Connection.begin` method has been called) when :meth:`.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:`.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:`.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:`.Connection.invalidate` method, just like auto-invalidation, will at the connection pool level invoke the :meth:`.PoolEvents.invalidate` event. .. seealso:: :ref:`pool_connection_invalidation` NrRT) rHrFrrTr,rXr invalidater)r! exceptionr&r&r'rbs'  zConnection.invalidatecCs|jdS)aDetach 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:`.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)rdetachr+r&r&r'rd3szConnection.detachcCs6|jr|jS|jdurt||_|jSt||jS)a4Begin 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:`.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:`.Connection.begin_nested` - use a SAVEPOINT :meth:`.Connection.begin_twophase` - use a two phase /XID transaction :meth:`.Engine.begin` - context manager available from :class:`.Engine` N)rbeginrRootTransaction Transactionr+r&r&r'reNs #    zConnection.begincCs>|jr|jS|jdurt||_|jSt||j|_|jS)a+Begin 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:`.Connection.begin` :meth:`.Connection.begin_twophase` N)r begin_nestedrrfNestedTransactionr+r&r&r'rhzs   zConnection.begin_nestedcCsN|jr |jj|dS|jdurtd|dur|jj}t|||_|jS)aBegin 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:`.Connection.begin` :meth:`.Connection.begin_twophase` )xidNzOCannot start a two phase transaction when a transaction is already in progress.) rbegin_twophaserrrSrr create_xidTwoPhaseTransactionr!rjr&r&r'rks   zConnection.begin_twophasecCs|jj|Sr4)rrdo_recover_twophaser+r&r&r'recover_twophasezConnection.recover_twophasecC|jjj|||ddSN)recover)rrdo_rollback_twophaser!rjrtr&r&r'rollback_preparedzConnection.rollback_preparedcCrrrs)rrdo_commit_twophaservr&r&r'commit_preparedrxzConnection.commit_preparedcCs |jjduS)z,Return True if a transaction is in progress.N)r,rr+r&r&r'in_transactions zConnection.in_transactionc Cs|jrJ|jr|jjd|js|jjr|j|z|jj |j |j j dur2||j _ WdSWdSt yP}z| |ddddWYd}~dSd}~ww)NzBEGIN (implicit))rrrloggerrZrrrerdo_beginr" _reset_agentrKrL)r! transactionrNr&r&r' _begin_impls    zConnection._begin_implc Cs|jrJ|js |jjr|j||jrl|jr|jjdz:z |jj |j Wnt yE}z| |ddddWYd}~nd}~wwW|jsU|j j|jurUd|j _d|_dS|jsh|j j|jurhd|j _d|_wd|_dS)NROLLBACK)rrrrrollbackrYrr|rZr do_rollbackr"rKrLrr~rrMr&r&r'_rollback_impls0    zConnection._rollback_implc Cs|jrJ|js |jjr|j||jr|jjdz:z |jj |j Wnt yB}z| |ddddWYd}~nd}~wwW|j sR|j j|jurRd|j _d|_dS|j se|j j|jured|j _d|_w)NCOMMIT)rrrrcommitrr|rZr do_commitr"rKrLrr~r)r! autocommitrNr&r&r' _commit_impls,   zConnection._commit_implcCsd|jrJ|js |jjr|j|||dur#|jd7_d|j}|jr0|jj|||SdS)Nrzsa_savepoint_%s) rrrr savepointrrYr do_savepoint)r!namer&r&r'_savepoint_impls  zConnection._savepoint_implcCH|jrJ|js |jjr|j||||jr|jj||||_dSr4) rrrrrollback_savepointrYrdo_rollback_to_savepointrr!rcontextr&r&r'_rollback_to_savepoint_impl   z&Connection._rollback_to_savepoint_implcCrr4) rrrrrelease_savepointrYrdo_release_savepointrrr&r&r'_release_savepoint_implrz"Connection._release_savepoint_implcCst|jrJ|jr|jjd|js|jjr|j||j|j r6|jj ||j|j j dur8||j _ dSdSdS)NzBEGIN TWOPHASE (implicit))rrrr|rZrrrkrjrYrdo_begin_twophaser"r~)r!rr&r&r'_begin_twophase_impls   zConnection._begin_twophase_implcCsT|jrJ|js |jjr|j|||jr(t|jtsJ|jj ||dSdSr4) rrrrprepare_twophaserY isinstancerrmrdo_prepare_twophasernr&r&r'_prepare_twophase_impl-s z!Connection._prepare_twophase_implcC|jrJ|js |jjr|j||||jrIt|jtsJz|jj |||W|j j |jur5d|j _ d|_dS|j j |jurEd|j _ d|_wd|_dSr4) rrrrrollback_twophaserYrrrmrrur"r~r!rj is_preparedr&r&r'_rollback_twophase_impl7s   z"Connection._rollback_twophase_implcCrr4) rrrrcommit_twophaserYrrrmrryr"r~rr&r&r'_commit_twophase_implJs   z Connection._commit_twophase_implcCs|js |jdSdSr4)r,r{rr+r&r&r' _autorollback[s zConnection._autorollbackcCs|jr'zz|`Wn tyYnwWd|_dSWd|_dSd|_YdSz|j}Wn ty5Ynw||j|jurCd|_|jsH|`d|_d|_dS)a8Close this :class:`.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` referenced by the :class:`.Engine` that produced this :class:`.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:`.Connection`. After :meth:`~.Connection.close` is called, the :class:`.Connection` is permanently in a closed state, and will allow no further operations. FN)rrrIrr7r~rr)r!connr&r&r'r7_s4      zConnection.closecO|j|g|Ri|S)zExecutes and returns the first column of the first row. The underlying result/cursor is closed after execution. executescalar)r!object_ multiparamsparamsr&r&r'rszConnection.scalarcOsNt|tjdr||||Sz|j}Wn ty t|w||||S)aExecutes a SQL statement construct and returns a :class:`.ResultProxy`. :param object: The statement to be executed. May be one of: * a plain string * any :class:`.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 `_ 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)rr string_types _execute_text_execute_on_connectionrIrObjectNotExecutableError)r!rrrmethr&r&r'rs;    zConnection.executecCs||||S)z%Execute a sql.FunctionElement object.)_execute_clauseelementselect)r!funcrrr&r&r'_execute_functionszConnection._execute_functionc Cs|js|jjr|jjD] }|||||\}}}q z&z|j}Wn ty)d}Ynw|dur2|}|j}|j |||}Wnt yY}z| |ddddWYd}~nd}~ww| d|d} |j rh||jso|jjry|j||||| | S)z&Execute a schema.ColumnDefault object.N)rrrbefore_executerrIrJrexecution_ctx_cls _init_defaultrKrL _exec_defaultrr7 after_execute) r!defaultrrfnrrctxrNretr&r&r'_execute_defaults6     zConnection._execute_defaultcCs|js|jjr|jjD] }|||||\}}}q |j}|j||jjs%|jndd}|||j j |d|}|js;|jjrE|j ||||||S)zExecute a schema.DDL object.N)rschema_translate_map) rrrrrcompiler is_default_execute_contextr _init_ddlr)r!ddlrrrrcompiledrr&r&r' _execute_ddls( zConnection._execute_ddlc Cs<|js|jjr|jjD] }|||||\}}}q t||}|r(t|d}ng}|j}d|jvrk||t t ||j j t |dkf}|jd|} | durj|j||t |dk|j js_|j ndd} | |jd|<n|j||t |dk|j js{|j ndd} |||jj| || |} |js|jjr|j||||| | S)z#Execute a sql.ClauseElement object.rcompiled_cacherN)r column_keysinliner)rrrrrlistkeysrrtuplesortedrhash_keylengetrrrr_init_compiledr) r!elemrrrdistilled_paramsrrkey compiled_sqlrr&r&r'rs\        z!Connection._execute_clauseelementcC~|js|jjr|jjD] }|||||\}}}q |j}t||}|||jj||||}|js3|jjr=|j ||||||S)zExecute a sql.Compiled object.) rrrrrrrrrr)r!rrrrr parametersrr&r&r'_execute_compiledS(    zConnection._execute_compiledcCr)zExecute a string SQL statement.) rrrrrrrr_init_statementr)r! statementrrrrrrr&r&r'rlrzConnection._execute_textc Gsz%z|j}Wn tyd}Ynw|dur|}||||g|R}WntyC}z||t||ddWYd}~nd}~ww|jrK||j |j |j } }}|j s]|d}|j sd|jj rw|jjD]} | || ||||j \}}qh|jr|jj||jjs|jjdtj|d|j dn|jjdd} zs|j r|jj r|jjjD] } | | |||rd} nq| s|j| |||nK|s|jr|jj r|jjjD] } | | ||rd} nq| s|j| ||n%|jj r|jjjD]} | | |||rd} nq| s|j| |||Wnty-}z||||| |WYd}~nd}~ww|j s7|jj rC|j|| ||||j |jrK||jsS|jrX| } n|!} | j"durf| #|j$rx|j%j&durx|j%j'dd |j(r| j)r|*| Sd| _+| S) z\Create an :class:`.ExecutionContext` and execute, returning a :class:`.ResultProxy`.Nr%r )batchesismultiz3[SQL parameters hidden due to hide_parameters=True]FT)r),rrIrJrKrLr text_typerpre_execcursorrr executemanyrrrbefore_cursor_executerr|rZhide_parameterssql_util _repr_paramsrdo_executemany no_parametersdo_execute_no_params do_executeafter_cursor_execute post_execis_crudis_text_setup_crud_result_proxyget_result_proxy _metadata _soft_closeshould_autocommitr,rrr _soft_closedr7_autoclose_connection) r!r constructorrrargsrrrNrr evt_handledresultr&r&r'rs             zConnection._execute_contextc Cs|js|jjr|jjD] }||||||d\}}q |jr+|jj||jjd|z"|jjs2dn|jjjD] }|||||rBn q7|j||||Wnt yh}z| |||||WYd}~nd}~ww|jsp|jjr}|j |||||ddSdS)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|rZrrrKrLr)r!rrrrrrNr&r&r'_cursor_execute s:     zConnection._cursor_executecCs8z|WdSty|jjjjdddYdSw)z\Close the given cursor, catching exceptions and turning into log warnings. zError closing cursorT)exc_infoN)r7 Exceptionrpoolr|error)r!rr&r&r'_safe_close_cursor1s   zConnection._safe_close_cursorc CsVt}|r|jdur||_t|t }|js>t||jjjo0|j o0|j ||j s-|j nd|p6|o6|j |_|r>|j|_ | }|j rbttjj||||jjj|jj|j|dur\|jndd|d|_ zt||jjjpy|duoy|duoy| } | rtjj||||jjj|jj|j|j|dur|jndd} nd} d} |js|jjr |jdds | r|r|j||||||t|| |j||||||j| } |jjD]&} z| | }|dur|| _} Wqty}z |} WYd}~nd}~ww|j| j kr| j |_| r| j | _| j}| r|r| ||js=|r"|!|tj"dd |#Wdn 1s8wY| rGt| |n| rQt| |ntj$|W|` |jrv|`|j sv|j }|rq|jj%&|||'||j(r|)dSdS|` |jr|`|j s|j }|r|jj%&|||'||j(r|)ww)N)rrrT)rconnection_invalidatedrrskip_user_error_eventsF) warn_only)*sysrrcrr_is_disconnectrdbapiErrorrF is_disconnectrHr_reentrant_errorr raise_from_causer DBAPIErrorinstancerrrrrrr dbapi_errorExceptionContextImpl handle_errorchained_exceptionrinvalidate_pool_on_disconnecthandle_dbapi_exceptionr safe_reraiserreraiser _invalidaterbrr7)r!rNrrrrris_exit_exceptionr should_wrapsqlalchemy_exceptionnewraiserrper_fn_raiseddbapi_conn_wrapperr&r&r'rLAs                 z"Connection._handle_dbapi_exceptionc Cst}||dd}t||jj}|r$tjjdd||jj|j |d}nd}d}|j rpt |||ddddd|d } |j j D]&} z| | } | durL| | _}Wq<tyb} z | }WYd} ~ nd} ~ ww|rp|| jkrp| j|_}|rzt||dS|rt||dStj|dS)N)rrT)rrr rrr rr rrrrrrrrrr r r) clsrNrrrr rrrrrrrr&r&r'$_handle_dbapi_exception_noconnections^   z/Connection._handle_dbapi_exception_noconnectionc Osp|}z|j|g|Ri|}||WSt|WdYdS1s0wYYdS)a8Execute the given function within a transaction boundary. The function is passed this :class:`.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:`.Connection.begin`:: with conn.begin(): conn.execute("some statement", {'x':5, 'y':10}) As well as with :meth:`.Engine.begin`:: with engine.begin() as conn: conn.execute("some statement", {'x':5, 'y':10}) .. seealso:: :meth:`.Engine.begin` - engine-level transactional context :meth:`.Engine.transaction` - engine-level version of :meth:`.Connection.transaction` N)re run_callablerr rr)r! callable_rr_transrr&r&r'rs*  &zConnection.transactioncOs||g|Ri|S)aGiven a callable object or function, execute it, passing a :class:`.Connection` as the first argument. The given \*args and \**kwargs are passed subsequent to the :class:`.Connection` argument. This function, along with :meth:`.Engine.run_callable`, allows a function to be run with a :class:`.Connection` or :class:`.Engine` object without the need to know which one is being dealt with. r&)r!r"rr_r&r&r'r!Bs zConnection.run_callablecKs||j|fi||dSr4)rtraverse_single)r!visitorcallableelementr_r&r&r' _run_visitorQszConnection._run_visitor)NFNNNNr4F)C__name__ __module__ __qualname____doc__r _schema_getterrr(r)propertyr,r2r5r<rArDrFrHr"rOrPrJrXrYrZr]r`rbrdrerhrkrprwrzr{rrrrrrrrrrrr7rrrrrrrrrrrr rrL classmethodr rr!r'r&r&r&r'r s  :     $      2, !        -D#9 (  :3 r c@seZdZdZddZdS)rz3Implement the :class:`.ExceptionContext` interface.c Cs:||_||_||_||_||_||_||_| |_| |_dSr4) rr"roriginal_exceptionexecution_contextrrr r) r!rcrrr"rrrrr rr&r&r'r(Xs  zExceptionContextImpl.__init__N)r)r*r+r,r(r&r&r&r'rUs rc@s\eZdZdZddZeddZddZdd Zd d Z d d Z ddZ ddZ ddZ dS)rga?Represent a database transaction in progress. The :class:`.Transaction` object is procured by calling the :meth:`~.Connection.begin` method of :class:`.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:`.Connection.begin` method:: with connection.begin(): connection.execute("insert into x (a, b) values (1, 2)") The Transaction object is **not** threadsafe. .. seealso:: :meth:`.Connection.begin` :meth:`.Connection.begin_twophase` :meth:`.Connection.begin_nested` .. index:: single: thread safety; Transaction cCs||_||_d|_dS)NT)r"_actual_parent is_activer!r"parentr&r&r'r( zTransaction.__init__cCs |jp|Sr4)r2r+r&r&r'_parents zTransaction._parentcCs&|jjsdS|j|ur|dSdS)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)r7r3rr+r&r&r'r7s    zTransaction.closecCs|jjsdS|d|_dS)z/Roll back this :class:`.Transaction`. NF)r7r3 _do_rollbackr+r&r&r'rs zTransaction.rollbackcCs|jdSr4)r7rr+r&r&r'r8rqzTransaction._do_rollbackcCs$|jjs td|d|_dS)z"Commit this :class:`.Transaction`.This transaction is inactiveFN)r7r3rrS _do_commitr+r&r&r'rs  zTransaction.commitcCsdSr4r&r+r&r&r'r:r6zTransaction._do_commitcCr3r4r&r+r&r&r'r5r6zTransaction.__enter__c Csj|dur/|jr/z|WdSt|WdYdS1s'wYYdS|dSr4)r3rr rrr8r&r&r'r<s  & zTransaction.__exit__N)r)r*r+r,r(r.r7r7rr8rr:r5r<r&r&r&r'rgps$   rgcs,eZdZfddZddZddZZS)rfcs"tt||d|j|dSr4)superrfr(r"r)r!r"r-r&r'r(zRootTransaction.__init__cC|jr |jdSdSr4)r3r"rr+r&r&r'r8zRootTransaction._do_rollbackcCr>r4)r3r"rr+r&r&r'r:r?zRootTransaction._do_commit)r)r*r+r(r8r: __classcell__r&r&r<r'rfs rfcs0eZdZdZfddZddZddZZS)rizRepresent a 'nested', or SAVEPOINT transaction. A new :class:`.NestedTransaction` object may be procured using the :meth:`.Connection.begin_nested` method. The interface is the same as that of :class:`.Transaction`. cs"tt||||j|_dSr4)r;rir(r"r _savepointr4r<r&r'r(r=zNestedTransaction.__init__cC |jr|j|j|jdSdSr4)r3r"rrAr7r+r&r&r'r8 zNestedTransaction._do_rollbackcCrBr4)r3r"rrAr7r+r&r&r'r:rCzNestedTransaction._do_commit)r)r*r+r,r(r8r:r@r&r&r<r'ris  rics8eZdZdZfddZddZddZdd ZZS) rmaRepresent a two-phase transaction. A new :class:`.TwoPhaseTransaction` object may be procured using the :meth:`.Connection.begin_twophase` method. The interface is the same as that of :class:`.Transaction` with the addition of the :meth:`prepare` method. cs.tt||dd|_||_|j|dS)NF)r;rmr( _is_preparedrjr"r)r!r"rjr<r&r'r(szTwoPhaseTransaction.__init__cCs*|jjs td|j|jd|_dS)zqPrepare this :class:`.TwoPhaseTransaction`. After a PREPARE, the transaction can be committed. r9TN)r7r3rrSr"rrjrDr+r&r&r'prepare s  zTwoPhaseTransaction.preparecC|j|j|jdSr4)r"rrjrDr+r&r&r'r8z TwoPhaseTransaction._do_rollbackcCrFr4)r"rrjrDr+r&r&r'r:rGzTwoPhaseTransaction._do_commit) r)r*r+r,r(rEr8r:r@r&r&r<r'rms   rmc@sReZdZdZeZdZeZ e dZ     dddZ!d d!Z"d"d#Z#d$d%Z$d&d'Z%d?d(d)Z&d*d+Z'd,d-Z(e)d.d/d>d0d1Z*d>d2d3Z+d?d4d5Z,d=d6d7Z-d8d9Z.d=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` object is instantiated publicly using the :func:`~sqlalchemy.create_engine` function. .. seealso:: :doc:`/core/engines` :ref:`connections_toplevel` FNc Csd||_||_||_|r||_||_||_tj||d|r$tj |||r0|j di|dSdSN)echoflagr&) rurlr logging_nameechorr instance_loggerr ConnectionProxy_adapt_listenerupdate_execution_options) r!rrrKrLrMproxyrArr&r&r'r(Ds zEngine.__init__cCr3r4r&r+r&r&r'r\sz Engine.enginecKs.|j||_|j|||j||dS)aUpdate the default execution_options dictionary of this :class:`.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:`.create_engine`. .. seealso:: :meth:`.Connection.execution_options` :meth:`.Engine.execution_options` N)rr>rset_engine_execution_optionsrr!r@r&r&r'rQ`szEngine.update_execution_optionscKs t||S)a Return a new :class:`.Engine` that will provide :class:`.Connection` objects with the given execution options. The returned :class:`.Engine` remains related to the original :class:`.Engine` in that it shares the same connection pool and other state: * The :class:`.Pool` used by the new :class:`.Engine` is the same instance. The :meth:`.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` inherits the events of the parent, and new events can be associated with the new :class:`.Engine` individually. * The logging configuration and logging_name is copied from the parent :class:`.Engine`. The intent of the :meth:`.Engine.execution_options` method is to implement "sharding" schemes where multiple :class:`.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:`.Connection` objects that will contain the execution option ``shard_id=shard1``, and ``shard2`` will produce :class:`.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:`.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:`.Connection.execution_options` - update execution options on a :class:`.Connection` object. :meth:`.Engine.update_execution_options` - update the execution options for a given :class:`.Engine` in place. :meth:`.Engine.get_execution_options` ) OptionEnginerTr&r&r'rAus BzEngine.execution_optionscCrB)z Get the non-SQL options which will take effect during execution. .. versionadded: 1.3 .. seealso:: :meth:`.Engine.execution_options` rCr+r&r&r'rDrEzEngine.get_execution_optionscCrG)ziString name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`.)rrr+r&r&r'rz Engine.namecCrG)ziDriver name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`.)rdriverr+r&r&r'rWrVz Engine.drivercCs d|jS)Nz Engine(%r))rKr+r&r&r'__repr__s zEngine.__repr__cCs&|j|j|_|j|dS)aDispose of the connection pool used by this :class:`.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`, so when they are closed individually, eventually the :class:`.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` isn't used again, no new connections will be made. .. seealso:: :ref:`engine_disposal` N)rdisposerecreaterengine_disposedr+r&r&r'rYs  zEngine.disposecCs:|}||diWdS1swYdS)Nr&)r`r)r!rrr&r&r'rs  $zEngine._execute_defaultccsH|dur| }|VWddS1swYdS|VdSr4r`)r!r"rr&r&r'_optional_conn_ctx_managers  " z!Engine._optional_conn_ctx_managercKsD||}|j||fi|WddS1swYdSr4)r]r')r!r%r&r"r_rr&r&r'r's "zEngine._run_visitorc@s$eZdZddZddZddZdS)zEngine._trans_ctxcCs||_||_||_dSr4)rrr#)r!rrr#r&r&r'r(r6zEngine._trans_ctx.__init__cCrBr4)rr+r&r&r'r5 szEngine._trans_ctx.__enter__cCs6|dur |jn|j|js|jdSdSr4)rrrr#rr7r8r&r&r'r< s   zEngine._trans_ctx.__exit__N)r)r*r+r(r5r<r&r&r&r' _trans_ctxs r^c Cs`|j|d}z|}Wnt |Wdn1s#wYYt|||S)aReturn a context manager delivering a :class:`.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:`.Connection` will be closed when the operation is complete. When set to ``True``, it indicates the :class:`.Connection` is in "single use" mode, where the :class:`.ResultProxy` returned by the first call to :meth:`.Connection.execute` will close the :class:`.Connection` when that :class:`.ResultProxy` has exhausted all result rows. .. seealso:: :meth:`.Engine.connect` - procure a :class:`.Connection` from an :class:`.Engine`. :meth:`.Connection.begin` - start a :class:`.Transaction` for a particular :class:`.Connection`. r#N)r`rer rr7rHr^)r!r#rr#r&r&r'res    z Engine.begincOD|}|j|g|Ri|WdS1swYdS)aExecute the given function within a transaction boundary. The function is passed a :class:`.Connection` newly procured from :meth:`.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.begin`:: with engine.begin() as conn: conn.execute("some statement", {'x':5, 'y':10}) .. seealso:: :meth:`.Engine.begin` - engine-level transactional context :meth:`.Connection.transaction` - connection-level version of :meth:`.Engine.transaction` N)r`rr!r"rr_rr&r&r'r;s '$zEngine.transactioncOr`)aGiven a callable object or function, execute it, passing a :class:`.Connection` as the first argument. The given \*args and \**kwargs are passed subsequent to the :class:`.Connection` argument. This function, along with :meth:`.Connection.run_callable`, allows a function to be run with a :class:`.Connection` or :class:`.Engine` object without the need to know which one is being dealt with. N)r`r!rar&r&r'r!es $zEngine.run_callablecOs$|jdd}|j|g|Ri|S)aExecutes the given construct and returns a :class:`.ResultProxy`. The arguments are the same as those used by :meth:`.Connection.execute`. Here, a :class:`.Connection` is acquired using the :meth:`~.Engine.contextual_connect` method, and the statement executed with that connection. The returned :class:`.ResultProxy` is flagged such that when the :class:`.ResultProxy` is exhausted and its underlying cursor is closed, the :class:`.Connection` created here will also be closed, which allows its associated DBAPI connection resource to be returned to the connection pool. Tr_)r`r)r!rrrr"r&r&r'rus zEngine.executecOrr4r)r!rrrr&r&r'rsz Engine.scalarcC|jdd}||||SNTr_)r`r)r!rrrr"r&r&r'r zEngine._execute_clauseelementcCrbrc)r`r)r!rrrr"r&r&r'rrdzEngine._execute_compiledcKs|j|fi|S)aOReturn a new :class:`.Connection` object. The :class:`.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` referenced by this :class:`.Engine`. When the :meth:`~.Connection.close` method of the :class:`.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.connect`. )r*r^r&r&r'r]szEngine.connectz1.3zThe :meth:`.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`, use the :meth:`.Engine.connect` method.cKs|jdd|i|S)aReturn a :class:`.Connection` object which may be part of some ongoing context. By default, this method does the same thing as :meth:`.Engine.connect`. Subclasses of :class:`.Engine` may override this method to provide contextual behavior. :param close_with_result: When True, the first :class:`.ResultProxy` created by the :class:`.Connection` will call the :meth:`.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.execute` method. r#Nr&r\r!r#r_r&r&r'contextual_connects zEngine.contextual_connectcKs$|j|||jjdfd|i|S)Nr#)r*_wrap_pool_connectrr]rer&r&r'r`szEngine._contextual_connectcCs<||}|j||WdS1swYdS)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]rget_table_names)r!r r"rr&r&r' table_namess $zEngine.table_namescCs||jj||S)aUReturn True if the given backend has a table of the given name. .. seealso:: :ref:`metadata_reflection_inspector` - detailed schema inspection using the :class:`.Inspector` interface. :class:`.quoted_name` - used to pass quoting information along with a schema identifier. )r!r has_table)r! table_namer r&r&r'rjs zEngine.has_tablec Csn|j}z|WS|jjy6}z!|durt|||ntjtWYd}~dSWYd}~dSd}~wwr4) rrr r r r rrr)r!rr"rrNr&r&r'rgszEngine._wrap_pool_connectcCs||jj|S)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:`.Connection` is not needed. When a :class:`.Connection` object is already present, the DBAPI connection is available using the :attr:`.Connection.connection` accessor. .. seealso:: :ref:`dbapi_connections` )rgrunique_connection)r!rQr&r&r'rszEngine.raw_connection)NNNNFr4r()NN)0r)r*r+r,r immutabledictrrr r*r r-rr(r.rrQrArDrrWr echo_propertyrMrXrYr contextlibcontextmanagerr]r'objectr^rerr!rrrrr] deprecatedrfr`rirjrgrr&r&r&r'rHsb   D     '*      rHc@sLeZdZdZddZddZddZeeeZdd Z d d Z ee e Z d S) rUFcCsj||_|j|_|j|_|j|_|j|_|j|_tj||jd|j |j|_|j |_ |j di|dSrI) _proxiedrKrrLrMrr rNrrrrQ)r!proxiedrAr&r&r'r( szOptionEngine.__init__cCrGr4rsrr+r&r&r' _get_pool$ razOptionEngine._get_poolcCs ||j_dSr4ru)r!rr&r&r' _set_pool' r=zOptionEngine._set_poolcCs|jjp |jddS)NrF)rsrr/rr+r&r&r'_get_has_events, szOptionEngine._get_has_eventscCs||jd<dS)Nr)r/)r!r:r&r&r'_set_has_events1 rqzOptionEngine._set_has_eventsN) r)r*r+_sa_propagate_class_eventsr(rvrwr.rrxryrr&r&r&r'rU s rU) __future__rrorr rrr rrr sqlr rr rrqrgrfrirm IdentifiedrHrUr&r&r&r'sH          Ec#k