ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ 4]c@srddlmZddlZddlZddlmZddlmZddlmZddl m Z dd l mZdd l m Z dd l mZdd l m Z dd l mZd efdYZdefdYZdefdYZdefdYZdefdYZdefdYZdee jfdYZdefdYZdS(i(twith_statementNi(t Connectable(tExceptionContext(t_distill_paramsi(texc(t interfaces(tlog(tutil(tschemat ConnectioncBs~eZdZejd9Zd9ed9d9d9d9dZdZ e dZ dZ dZ dZdZdZe d Ze d Ze d Zd Ze d ZdZe dZe dZe dZdZdZd9dZdZdZdZd9dZ dZ!edZ"edZ#dZ$dZ%dZ&edZ'd9d Z(d!Z)d"Z*d#Z+d$Z,d%Z-d&Z.d'Z/d(Z0d)Z1d*Z2d+Z3d,Z4d-Z5d.Z6d/Z7d0Z8d1Z9d9d2Z:d3Z;eZ<eZ=d4Z>e?d5Z@d6ZAd7ZBd8ZCRS(:s: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 cCsn||_|j|_||_|dk |_|r~||_||_|j|_t|_ ||_ |j |_ |j |_ n|dk r|n |j |_d|_d|_||_ t|_t|_|jj|_|dkr|j j|j |_ n|p|dko|j |_ | s0t|j|_|j sQ|jj rj|j j||jndS(sConstruct 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. iN(tenginetdialectt_Connection__branch_fromtNonet_Connection__brancht_Connection__connectiont_execution_optionst_echotFalsetshould_close_with_resulttdispatcht _has_eventstschema_for_objecttraw_connectiont_Connection__transactiont_Connection__savepoint_seqt_Connection__invalidtTruet_Connection__can_reconnectt_should_log_infot_jointAssertionErrortengine_connect(tselfR t connectiontclose_with_resultt _branch_fromRt _dispatchR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt__init__Es8                 c CsT|jr|jjS|jj|j|jd|d|jd|jd|jSdS(sReturn 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%N(R t_branchR t_connection_clsRRRR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR's      cCs|jr|jS|SdS(sreturn the 'root' connection. Returns 'self' if this connection is not a branch, else returns the root connection from which we ultimately branched. N(R (R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_roots cCs+|jj|j}|jj|_|S(s3Create a shallow copy of this Connection. (t __class__t__new__t__dict__tcopy(R!tc((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_clonescCs|S(N((R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt __enter__scCs|jdS(N(tclose(R!ttype_tvaluet traceback((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt__exit__scKsc|j}|jj||_|js6|jjrL|jj||n|jj|||S(s% 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 (*not* the underlying DBAPI connection, for which the level is reset to its original setting upon termination 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. Note that this option necessarily affects the underlying DBAPI connection for the lifespan of the originating :class:`.Connection`, and is not per-execution. This setting is not removed until the underlying DBAPI connection is returned to the connection pool, i.e. the :meth:`.Connection.close` method is called. .. 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. .. versionchanged:: 0.9.9 A warning is emitted when the ``isolation_level`` execution option is used after a transaction has been started with :meth:`.Connection.begin` or similar. .. 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` (R/RtunionRR Rt set_connection_execution_optionsR (R!toptR.((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytexecution_optionss cCs|jS(s Get the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`.Connection.execution_options` (R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytget_execution_optionsXs cCsd|jko|j S(s)Return True if this connection is closed.R(R,R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytclosedcscCs |jjS(s/Return True if this connection was invalidated.(R)R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt invalidatedlscCs`y |jSWntk rnXy|jSWn,tk r[}|j|ddddnXdS(sThe underlying DB-API connection managed by this Connection. .. seealso:: :ref:`dbapi_connections` N(RtAttributeErrort_revalidate_connectiont BaseExceptiont_handle_dbapi_exceptionR (R!te((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR"rs   cCsJy|jj|jSWn,tk rE}|j|ddddnXdS(sReturn 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(R tget_isolation_levelR"R?R@R (R!RA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRBscCs |jjS(sThe 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 (R tdefault_isolation_level(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRCscCs|jr|jjS|jrq|jrq|jdk rItjdn|jj d||_ t |_|j Stj ddS(Ns8Can't reconnect until invalid transaction is rolled backt _connectionsThis Connection is closed( R R>RRRR RtInvalidRequestErrorR RRRtResourceClosedError(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR>s    cCst|jdtS(Ntis_valid(tgetattrRR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_connection_is_validscCs'|j o&|j o&t|jdtS(NRG(R;R<RHRR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt#_still_open_and_connection_is_valids  cCs |jjS(sInfo 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"tinfo(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRKs cCs |jS(siReturns 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!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytconnects cKs |jS(N(R'(R!tkwargs((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_contextual_connectscCsc|jr dS|jr(tjdn|jjrJ|jjj|n|j`t|j_ dS(sInvalidate 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` NsThis Connection is closed( R<R;RRFR)RIRt invalidateRR(R!t exception((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyROs'    cCs|jjdS(sDetach 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(Rtdetach(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRQ9scCsO|jr|jjS|jdkr;t||_|jSt||jSdS(s4Begin 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(R tbeginRR tRootTransactiont Transaction(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRRTs #  cCsS|jr|jjS|jdkr7t||_nt||j|_|jS(s+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 t begin_nestedRR RStNestedTransaction(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRUs   cCsw|jr|jjd|S|jdk r=tjdn|dkr^|jjj}nt |||_|jS(sBegin 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` txidsOCannot start a two phase transaction when a transaction is already in progress.N( R tbegin_twophaseRR RRER R t create_xidtTwoPhaseTransaction(R!RW((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRXs   cCs|jjj|S(N(R R tdo_recover_twophase(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytrecover_twophasescCs |jjj||d|dS(Ntrecover(R R tdo_rollback_twophase(R!RWR]((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytrollback_preparedscCs |jjj||d|dS(NR](R R tdo_commit_twophase(R!RWR]((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytcommit_preparedscCs|jjdk S(s,Return True if a transaction is in progress.N(R)RR (R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytin_transactionscCs|j st|jr/|jjjdn|jsD|jjrW|jj|ny;|jj j |j |j j dkr||j _ nWn,tk r}|j|ddddnXdS(NsBEGIN (implicit)(R RRR tloggerRKRRRRR tdo_beginR"t _reset_agentR R?R@(R!t transactionRA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _begin_impls cCs|j st|js%|jjr8|jj|n|jr|jr`|jjj dnzMy|jj j |j Wn,t k r}|j|ddddnXWd|j r|j j|jkrd|j _nd|_Xn d|_dS(NtROLLBACK(R RRR RtrollbackRJRRcRKR t do_rollbackR"R?R@R RReR(R!RA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_rollback_impls   !  cCs|j st|js%|jjr8|jj|n|jrW|jjjdnzMy|jj j |j Wn,t k r}|j |ddddnXWd|j r|j j|jkrd|j _nd|_XdS(NtCOMMIT(R RRR RtcommitRRcRKR t do_commitR"R?R@R RReR(R!t autocommitRA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _commit_impls ! cCs|j st|js%|jjr;|jj||n|dkrf|jd7_d|j}n|jr|jj j |||SdS(Nissa_savepoint_%s( R RRR Rt savepointR RRJR t do_savepoint(R!tname((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_savepoint_impls  cCsm|j st|js%|jjr>|jj|||n|jr`|jjj||n||_ dS(N( R RRR Rtrollback_savepointRJR tdo_rollback_to_savepointR(R!Rstcontext((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_rollback_to_savepoint_impls  cCsm|j st|js%|jjr>|jj|||n|jr`|jjj||n||_ dS(N( R RRR Rtrelease_savepointRJR tdo_release_savepointR(R!RsRw((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_release_savepoint_impls  cCs|j st|jr/|jjjdn|jsD|jjr]|jj||j n|j r|jj j ||j |j jdkr||j _qndS(NsBEGIN TWOPHASE (implicit)(R RRR RcRKRRRXRWRJR tdo_begin_twophaseR"ReR (R!Rf((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_begin_twophase_impl%s  cCsy|j st|js%|jjr;|jj||n|jrut|jt s\t|jj j ||ndS(N( R RRR Rtprepare_twophaseRJt isinstanceRRZR tdo_prepare_twophase(R!RW((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_prepare_twophase_impl3s  cCs|j st|js%|jjr>|jj|||n|jrt|jt s_tz|jj j |||Wd|j j |jkrd|j _ nd|_Xn d|_dS(N(R RRR Rtrollback_twophaseRJRRRZR R^R"ReR (R!RWt is_prepared((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_rollback_twophase_impl=s   cCs|j st|js%|jjr>|jj|||n|jrt|jt s_tz|jj j |||Wd|j j |jkrd|j _ nd|_Xn d|_dS(N(R RRR Rtcommit_twophaseRJRRRZR R`R"ReR (R!RWR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_commit_twophase_implPs  cCs#|jjs|jjndS(N(R)RbRk(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _autorollbackascCs|jr?z"y |`Wntk r)nXWdt|_dSXny |j}Wntk r_n;X|j|j|jkrd|_n|j s|`nt|_d|_dS(s8Close 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. N( R RR=RRR1ReRR R(R!tconn((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR1es&           cOs|j|||jS(sExecutes and returns the first column of the first row. The underlying result/cursor is closed after execution. (texecutetscalar(R!tobject_t multiparamstparams((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRscOsmt|tjdr)|j|||Sy |j}Wn tk rXtj|nX||||SdS(sExecutes 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. iN(RRt string_typest _execute_textt_execute_on_connectionR=RtObjectNotExecutableError(R!RRRtmeth((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs;  cCs|j|j||S(s%Execute a sql.FunctionElement object.(t_execute_clauseelementtselect(R!tfuncRR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_execute_functionsc CsF|js|jjrMx5|jjD]$}|||||\}}}q"Wnygy |j}Wntk rvd}nX|dkr|j}n|j}|j j |||}Wn,t k r}|j |ddddnX|j d|d} |jr|jn|js#|jjrB|jj||||| n| S(s&Execute a schema.ColumnDefault object.N(RR Rtbefore_executeRR=R R>R texecution_ctx_clst _init_defaultR?R@t _exec_defaultRR1t after_execute( R!tdefaultRRtfnRR tctxRAtret((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_execute_defaults,"        cCs|js|jjrMx5|jjD]$}|||||\}}}q"Wn|j}|jd|d|jjsz|jnd}|j ||j j |d|}|js|jjr|jj |||||n|S(sExecute a schema.DDL object.R tschema_translate_mapN( RR RRR tcompileRt is_defaultR t_execute_contextRt _init_ddlR(R!tddlRRRR tcompiledR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _execute_ddls"%     c Cs|js|jjrMx5|jjD]$}|||||\}}}q"Wnt||}|r{t|dj}ng}|j}d|jkrJ||t t ||j j t |dkf}|jdj|} | dkr|jd|d|dt |dkd|j js*|j nd} | |jd|R?R@Rt text_typeRtpre_exectcursorRRt executemanyRR Rtbefore_cursor_executeRRcRKtsql_utilt _repr_paramsRR tdo_executemanyRt no_parameterstdo_execute_no_paramst do_executetafter_cursor_executet post_exectis_crudtis_textt_setup_crud_result_proxytget_result_proxyt _metadatat _soft_closetshould_autocommitR)RRpRt _soft_closedR1t_autoclose_connection( R!R t constructorRRtargsRRwRARRt evt_handledtresult((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs                               cCsQ|js|jjrPx8|jjD]'}||||||t\}}q"Wn|jr|jjj||jjjd|nybx[|jjsdn |jjj D]}|||||rPqqW|jj ||||Wn,t k r}|j |||||nX|js+|jjrM|jj |||||tndS(s_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(). s%rN(( RR RRRRRcRKR RR?R@R(R!RRRRwRRA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_cursor_executes( %  cCsBy|jWn-tk r=|jjjjddtnXdS(s\Close the given cursor, catching exceptions and turning into log warnings. sError closing cursortexc_infoN(R1t ExceptionR tpoolRcterrorR(R!R((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_safe_close_cursor/s  c Cstj}|r-|jdkr-||_nt|t }|jst||jjj r|j r|jj ||j s|j nd|p|o|j |_|r|j|_ qn| }|jrtjtjj||||jjj d|j|nt|_zNt||jjj pG|dk oG|dkoG| } | rtjj||||jjj d|jd|j} nd} d} |js|jjr|jjdt r| r|r|jj||||||nt|| |j||||||j| } x]|jjD]O} y,| | }|dk rY|| _} nWq(tk rv}|} Pq(Xq(W|j| j kr| j |_| r| j | _qn| j }n| r|r|j!|n|js|r|j"|ntj#dt|j$WdQXn| r7tj| |n&| rPtj| |n tj%|Wd|`|jr|`|j s|j }|r|jj&j'||n|j(|qn|j)r|j*nXdS(NR tconnection_invalidatedtskip_user_error_eventst warn_only(+tsysRRPR RRt_is_disconnectR tdbapitErrorR;t is_disconnectR<Rt_reentrant_errorRtraise_from_causeRt DBAPIErrortinstanceRRR RRRRt dbapi_errortExceptionContextImplt handle_errortchained_exceptionRtinvalidate_pool_on_disconnectthandle_dbapi_exceptionRt safe_reraiseRtreraiseRt _invalidateRORR1(R!RARRRRwRtis_exit_exceptionRt should_wraptsqlalchemy_exceptiontnewraiseRRtper_fnt_raisedtdbapi_conn_wrapper((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR@?s                               c Csptj}|j|dd}t||jj}|rftjj dd||jjd|}nd}d}|j r-t |||ddddd|t } x]|j jD]O} y,| | } | dk r| | _}nWqtk r} | }PqXqW|r-|| jkr-| j|_}q-n|rFtj||n&|r_tj||n tj|dS(NR(RRRR RRRRRRRRRRRRRRRRR( tclsRAR R RRRRRRRRR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt$_handle_dbapi_exception_noconnectionsN         cOs^|j}y'|j|||}|j|SWn$tj|jWdQXnXdS(s8Execute 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(RRt run_callableRmRRRi(R!t callable_RRMttransR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRfs*   cOs||||S(sGiven 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!RRRM((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR7s cKs ||j||j|dS(N(R ttraverse_single(R!tvisitorcallabletelementRM((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _run_visitorFsN(Dt__name__t __module__t__doc__Rt_schema_getterR RRR&R'tpropertyR)R/R0R5R9R:R;R<R"RBRCR>RIRJRKRLRNRORQRRRURXR\R_RaRbRgRkRpRtRxR{R}RRRRR1RRRRRRRRRRRRRR@t classmethodRRfRR(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR s 2       $    2  ,  !            -  D  #  9   | (  : 3 RcBseZdZdZRS(s3Implement the :class:`.ExceptionContext` interface.c CsU||_||_||_||_||_||_||_| |_| |_dS(N( R R"Rtoriginal_exceptiontexecution_contextRRRR( R!RPRR R"RRRRwRR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&Ms        (RRRR&(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRJsRTcBseeZdZdZedZdZdZdZdZ dZ dZ d Z RS( s?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||_||_t|_dS(N(R"t_actual_parentRt is_active(R!R"tparent((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&s  cCs |jp |S(N(R (R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_parentscCs0|jjsdS|j|kr,|jndS(s;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 R Ri(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR1s cCs'|jjsdS|jt|_dS(s/Roll back this :class:`.Transaction`. N(R R t _do_rollbackR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRis  cCs|jjdS(N(R Ri(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRscCs5|jjstjdn|jt|_dS(s"Commit this :class:`.Transaction`.sThis transaction is inactiveN(R R RREt _do_commitR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRms  cCsdS(N((R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRscCs|S(N((R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR0scCs[|dkrM|jrMy|jWqWtj|jWdQXqWXn |jdS(N(R R RmRRRi(R!R2R3R4((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR5s ( RRRR&RR R1RiRRmRR0R5(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRTes#      RScBs#eZdZdZdZRS(cCs-tt|j|d|jj|dS(N(tsuperRSR&R R"Rg(R!R"((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&scCs|jr|jjndS(N(R R"Rk(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs cCs|jr|jjndS(N(R R"Rp(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs (RRR&RR(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRSs  RVcBs)eZdZdZdZdZRS(sRepresent 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`. cCs/tt|j|||jj|_dS(N(RRVR&R"Rtt _savepoint(R!R"R ((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&scCs)|jr%|jj|j|jndS(N(R R"RxRR (R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs  cCs)|jr%|jj|j|jndS(N(R R"R{RR (R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs  (RRRR&RR(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRVs  RZcBs2eZdZdZdZdZdZRS(sRepresent 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. cCs?tt|j|dt|_||_|jj|dS(N( RRZR&R Rt _is_preparedRWR"R}(R!R"RW((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&s  cCs>|jjstjdn|jj|jt|_dS(sqPrepare this :class:`.TwoPhaseTransaction`. After a PREPARE, the transaction can be committed. sThis transaction is inactiveN( R R RRER"RRWRR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytprepares cCs|jj|j|jdS(N(R"RRWR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR scCs|jj|j|jdS(N(R"RRWR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRs(RRRR&RRR(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRZs    tEnginecBseZdZejZeZeZ e j dZ dddddZedZdZdZdZedZedZejZdZd Zd Zejdd Zdd Zd e fdYZ!edZ"dZ#dZ$dZ%dZ&dddZ'dZ(dZ)ej*ddedZ+edZ,dddZ-ddZ.dZ/ddZ0RS( s{ 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` cCs||_||_||_|r-||_n||_tj|d||retjj ||n|r{|j |ndS(Ntechoflag( RturlR t logging_nametechoRtinstance_loggerRtConnectionProxyt_adapt_listenertupdate_execution_options(R!RR RRRtproxyR9((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&9s     cCs|S(N((R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR OscKs?|jj||_|jj|||jj||dS(sUpdate 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(RR6Rtset_engine_execution_optionsR (R!R8((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRSscKs t||S(s 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` (t OptionEngine(R!R8((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR9hsBcCs|jS(s Get the non-SQL options which will take effect during execution. .. versionadded: 1.3 .. seealso:: :meth:`.Engine.execution_options` (R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR:s cCs |jjS(siString name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`.(R Rs(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRsscCs |jjS(siDriver name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`.(R tdriver(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR scCs d|jS(Ns Engine(%r)(R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt__repr__scCs3|jj|jj|_|jj|dS(sDispose 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(RtdisposetrecreateRtengine_disposed(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR"s cCs,|j}|j|diSWdQXdS(N((RNR(R!RR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRsccs2|dkr)|j }|VWdQXn|VdS(N(R RN(R!R"R((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_optional_conn_ctx_managers cKs/|j|}|j|||WdQXdS(N(R%R(R!RRR"RMR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRst _trans_ctxcBs#eZdZdZdZRS(cCs||_||_||_dS(N(RRfR#(R!RRfR#((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&s  cCs|jS(N(R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR0scCsF|dk r|jjn |jj|jsB|jjndS(N(R RfRiRmR#RR1(R!R2R3R4((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR5s    (RRR&R0R5(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&s  cCs\|jd|}y|j}Wn$tj|jWdQXnXtj|||S(sReturn 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(RNRRRRR1RR&(R!R#RR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRRs cOs,|j}|j|||SWdQXdS(sExecute 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(RNRf(R!RRRMR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRf.s'cOs,|j}|j|||SWdQXdS(sGiven 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(RNR(R!RRRMR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRXs cOs%|jdt}|j|||S(sExecutes 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. R#(RNRR(R!RRRR"((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRhscOs|j|||jS(N(RR(R!RRR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR{scCs%|jdt}|j|||S(NR#(RNRR(R!RRRR"((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR~scCs%|jdt}|j|||S(NR#(RNRR(R!RRRR"((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRscKs|j||S(sOReturn 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!RM((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRLss1.3sThe :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|jd||S(sReturn 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#(RN(R!R#RM((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pytcontextual_connects cKs+|j||j|jjdd||S(NR#(R(t_wrap_pool_connectRRLR (R!R#RM((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRNs cCsD|j|/}|s'|jj}n|jj||SWdQXdS(sReturn 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 tdefault_schema_nametget_table_names(R!RR"R((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt table_namess cCs|j|jj||S(sUReturn 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. (RR t has_table(R!t table_nameR((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR,s cCsi|j}y |SWnN|jjk rd}|dkrNtj|||qetjtj nXdS(N( R RRR R RRRRR(R!RR"R RA((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR(s   cCs|j|jj|S(s&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` (R(Rtunique_connection(R!RD((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRsN(1RRRRt immutabledictRRRR R(RRR RR&RR RR9R:RsR Rt echo_propertyRR!R"Rt contextlibtcontextmanagerR%RtobjectR&RRRfRRRRRRLt deprecatedR'RNR+R,R(R(((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyRsP    D       ' *        RcBsYeZeZdZdZdZeeeZdZ dZ ee e Z RS(cCs||_|j|_|j|_|j|_|j|_tj|d|j|jj|j|_|j |_ |j |dS(NR( t_proxiedRR RRRRRRRR(R!tproxiedR9((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyR&s      cCs |jjS(N(R5R(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _get_pool scCs||j_dS(N(R5R(R!R((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt _set_pool scCs|jjp|jjdtS(NR(R5RR,RR(R!((sI/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/engine/base.pyt_get_has_events scCs||jds4  4c#