sqlalchemy :: engine :: threadlocal :: TLEngine :: Class TLEngine
[frames] | no frames]

Class TLEngine

      object --+        
               |        
base.Connectable --+    
                   |    
      object --+   |    
               |   |    
  log.Identified --+    
                   |    
         base.Engine --+
                       |
                      TLEngine

An Engine that includes support for thread-local managed transactions.

Instance Methods
 
__enter__(self)
 
__exit__(self, type, value, traceback)
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__repr__(self)
repr(x)
 
begin(self)
Return a context manager delivering a :class:`.Connection` with a :class:`.Transaction` established.
 
begin_nested(self)
 
begin_twophase(self, xid=None)
 
close(self)
 
commit(self)
 
contextual_connect(self, **kw)
Return a :class:`.Connection` object which may be part of some ongoing context.
 
dispose(self)
Dispose of the connection pool used by this :class:`.Engine`.
 
prepare(self)
 
rollback(self)

Inherited from base.Engine: connect, create, dispatch, drop, execute, has_table, raw_connection, reflecttable, run_callable, scalar, table_names, text, transaction, update_execution_options

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables

Inherited from base.Engine: echo

Inherited from log.Identified: logging_name

Properties
  closed

Inherited from base.Engine: driver, func, name

Inherited from object: __class__

Method Details

__init__(self, *args, **kwargs)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

begin(self)

 

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

.. versionadded:: 0.7.6

See also:

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

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

Overrides: base.Engine.begin
(inherited documentation)

contextual_connect(self, **kw)

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

Overrides: base.Connectable.contextual_connect
(inherited documentation)

dispose(self)

 
Dispose of the connection pool used by this :class:`.Engine`.

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.

This method has two general use cases:

 * When a dropped connection is detected, it is assumed that all
   connections held by the pool are potentially dropped, and 
   the entire pool is replaced.

 * An application may want to use :meth:`dispose` within a test 
   suite that is creating multiple engines.

It is critical to note that :meth:`dispose` does **not** guarantee
that the application will release all open database connections - only
those connections that are checked into the pool are closed.
Connections which remain checked out or have been detached from
the engine are not affected. 

Overrides: base.Engine.dispose
(inherited documentation)

Property Details

closed

Get Method:
unreachable.closed(self)