# SQLAlchemy 0.4 Documentation

Multiple Pages | One Page
Version: 0.4.4 Last Updated: 03/11/08 20:04:34

### module sqlalchemy.engine

SQL connections, SQL execution and high-level DB-API interface.

The engine package defines the basic components used to interface DB-API modules with higher-level statement construction, connection-management, execution and result contexts. The primary "entry point" class into this package is the Engine and it's public constructor `create_engine()`.

This package includes:

base.py
  Defines interface classes and some implementation classes which comprise the basic components used to interface between a DB-API, constructed and plain-text statements, connections, transactions, and results.
default.py
  Contains default implementations of some of the components defined in base.py. All current database dialects use the classes in default.py as base classes for their own database-specific implementations.
strategies.py
  The mechanics of constructing `Engine` objects are represented here. Defines the `EngineStrategy` class which represents how to go from arguments specified to the `create_engine()` function, to a fully constructed `Engine`, including initialization of connection pooling, dialects, and specific subclasses of `Engine`.
threadlocal.py
  The `TLEngine` class is defined here, which is a subclass of the generic `Engine` and tracks `Connection` and `Transaction` objects against the identity of the current thread. This allows certain programming patterns based around the concept of a "thread-local connection" to be possible. The `TLEngine` is created by using the "threadlocal" engine strategy in conjunction with the `create_engine()` function.
url.py
  Defines the `URL` class which represents the individual components of a string URL passed to `create_engine()`. Also defines a basic module-loading strategy for the dialect specifier within a URL.

### Module Functions

def create_engine(*args, **kwargs)

Create a new Engine instance.

The standard method of specifying the engine is via URL as the first positional argument, to indicate the appropriate database dialect and connection arguments, with additional keyword arguments sent as options to the dialect and resulting Engine.

The URL is a string in the form `dialect://user:password@host/dbname[?key=value..]`, where `dialect` is a name such as `mysql`, `oracle`, `postgres`, etc. Alternatively, the URL can be an instance of `sqlalchemy.engine.url.URL`.

**kwargs represents options to be sent to the Engine itself as well as the components of the Engine, including the Dialect, the ConnectionProvider, and the Pool. A list of common options is as follows:

poolclass
  a subclass of `sqlalchemy.pool.Pool` which will be used to instantiate a connection pool.
pool
  an instance of `sqlalchemy.pool.DBProxy` or `sqlalchemy.pool.Pool` to be used as the underlying source for connections (DBProxy/Pool is described in the previous section). This argument supercedes "poolclass".
echo
  defaults to False: if True, the Engine will log all statements as well as a repr() of their parameter lists to the engines logger, which defaults to `sys.stdout`. A Engine instances' echo data member can be modified at any time to turn logging on and off. If set to the string 'debug', result rows will be printed to the standard output as well.
logger
  defaults to None: a file-like object where logging output can be sent, if echo is set to True. This defaults to `sys.stdout`.
encoding
  defaults to 'utf-8': the encoding to be used when encoding/decoding Unicode strings.
convert_unicode
  defaults to False: true if unicode conversion should be applied to all str types.
module
  defaults to None: this is a reference to a DB-API 2.0 module to be used instead of the dialect's default module.
strategy

  allows alternate Engine implementations to take effect. Current implementations include `plain` and `threadlocal`. The default used by this function is `plain`.

  `plain` provides support for a Connection object which can be used to execute SQL queries with a specific underlying DB-API connection.

  `threadlocal` is similar to `plain` except that it adds support for a thread-local connection and transaction context, which allows a group of engine operations to participate using the same underlying connection and transaction without the need for explicitly passing a single Connection.

def engine_descriptors(*args, **kwargs)

Deprecated. Provide a listing of all the database implementations supported.

> deprecated - this method will be removed in 0.5.

def engine_from_config(configuration, prefix='sqlalchemy.', **kwargs)

Create a new Engine instance using a configuration dictionary.

The dictionary is typically produced from a config file where keys are prefixed, such as sqlalchemy.url, sqlalchemy.echo, etc. The 'prefix' argument indicates the prefix to be searched for.

A select set of keyword arguments will be "coerced" to their expected type based on string values. In a future release, this functionality will be expanded and include dialect-specific arguments.

### class BufferedColumnResultProxy(ResultProxy)

A ResultProxy with column buffering behavior.

`ResultProxy` that loads all columns into memory each time fetchone() is called. If fetchmany() or fetchall() are called, the full grid of results is fetched. This is to operate with databases where result rows contain "live" results that fall out of scope unless explicitly fetched. Currently this includes just cx_Oracle LOB objects, but this behavior is known to exist in other DB-APIs as well (Pygresql, currently unsupported).

def fetchall(self)
def fetchmany(self, size=None)
back to section top

### class BufferedColumnRow(RowProxy)

def __init__(self, parent, row)

Construct a new `BufferedColumnRow`.

back to section top

### class BufferedRowResultProxy(ResultProxy)

A ResultProxy with row buffering behavior.

`ResultProxy` that buffers the contents of a selection of rows before `fetchone()` is called. This is to allow the results of `cursor.description` to be available immediately, when interfacing with a DB-API that requires rows to be consumed before this information is available (currently psycopg2, when used with server-side cursors).

The pre-fetching behavior fetches only one row initially, and then grows its buffer size by a fixed amount with each successive need for additional rows up to a size of 100.

back to section top

### class Compiled(object)

Represent a compiled SQL expression.

The `__str__` method of the `Compiled` object should produce the actual text of the statement. `Compiled` objects are specific to their underlying database dialect, and also may or may not be specific to the columns referenced within a particular set of bind parameters. In no case should the `Compiled` object be dependent on the actual values of those bind parameters, even though it may reference those values as defaults.

def __init__(self, dialect, statement, column_keys=None, bind=None)

Construct a new `Compiled` object.

dialect
  `Dialect` to compile against.
statement
  `ClauseElement` to be compiled.
column_keys
  a list of column names to be compiled into an INSERT or UPDATE statement.
bind
  Optional Engine or Connection to compile this statement against.

def compile(self)

Produce the internal string representation of this element.

def construct_params(self, params)

Return the bind params for this compiled object.

params is a dict of string/object pairs whos values will override bind values compiled in to the statement.

def execute(self, *multiparams, **params)

Execute this compiled object.

def get_params(*args, **kwargs)

Deprecated. Use construct_params(). (supports unicode names)

def scalar(self, *multiparams, **params)

Execute this compiled object and return the result's scalar value.

back to section top

### class Connectable(object)

Interface for an object that can provide an Engine and a Connection object which correponds to that Engine.

def contextual_connect(self)

Return a Connection object which may be part of an ongoing context.

def create(self, entity, **kwargs)

Create a table or index given an appropriate schema object.

def drop(self, entity, **kwargs)

Drop a table or index given an appropriate schema object.

def execute(self, object, *multiparams, **params)
def execute_clauseelement(self, elem, multiparams=None, params=None)
back to section top

### class Connection(Connectable)

Provides high-level functionality for a wrapped DB-API connection.

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

The Connection object is not threadsafe.

def __init__(self, engine, connection=None, close_with_result=False, _branch=False)

Construct a new Connection.

Connection objects are typically constructed by an Engine, see the `connect()` and `contextual_connect()` methods of Engine.

def begin(self)

Begin a transaction and return a Transaction handle.

Repeated calls to `begin` on the same Connection will create a lightweight, emulated nested transaction. Only the outermost transaction may `commit`. Calls to `commit` on inner transactions are ignored. Any transaction in the hierarchy may `rollback`, however.

def begin_nested(self)

Begin a nested transaction and return a Transaction handle.

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.

def begin_twophase(self, xid=None)

Begin a two-phase or XA transaction and return a Transaction handle.

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

def close(self)

Close this Connection.

closed = property()

return True if this connection is closed.

def commit_prepared(self, xid, recover=False)
def connect(self)

Returns self.

This `Connectable` interface method returns self, allowing Connections to be used interchangably with Engines in most situations that require a bind.

connection = property()

The underlying DB-API connection managed by this Connection.

def contextual_connect(self, **kwargs)

Returns self.

This `Connectable` interface method returns self, allowing Connections to be used interchangably with Engines in most situations that require a bind.

def create(self, entity, **kwargs)

Create a Table or Index given an appropriate Schema object.

def default_schema_name(self)
def detach(self)

Detach the underlying DB-API connection from its connection pool.

This Connection instance will remain useable. When closed, the DB-API connection will be literally closed and not returned to its pool. The pool will typically lazily create a new connection to replace the detached connection.

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). Also see PoolListener for a mechanism to modify connection state when connections leave and return to their connection pool.

dialect = property()

Dialect used by this Connection.

def drop(self, entity, **kwargs)

Drop a Table or Index given an appropriate Schema object.

def execute(self, object, *multiparams, **params)

Executes and returns a ResultProxy.

def execute_clauseelement(self, elem, multiparams=None, params=None)
def in_transaction(self)

Return True if a transaction is in progress.

info = property()

A collection of per-DB-API connection instance properties.

def invalidate(self, exception=None)

Invalidate the underlying DBAPI connection associated with this Connection.

The underlying DB-API 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 usage, this Connection will attempt to reconnect to the pool with a new connection.

Transactions in progress remain in an "opened" state (even though the actual transaction is gone); these must be explicitly rolled back before a reconnect on this Connection can proceed. This is to prevent applications from accidentally continuing their transactional operations in a non-transactional state.

invalidated = property()

return True if this connection was invalidated.

properties = property()

An alias for the .info collection, will be removed in 0.5.

def recover_twophase(self)
def reflecttable(self, table, include_columns=None)

Reflect the columns in the given string table name from the database.

def rollback_prepared(self, xid, recover=False)
def run_callable(self, callable_)
def scalar(self, object, *multiparams, **params)

Executes and returns the first column of the first row.

The underlying result/cursor is closed after execution.

should_close_with_result = property()

Indicates if this Connection should be closed when a corresponding ResultProxy is closed; this is essentially an auto-release mode.

def statement_compiler(self, statement, **kwargs)
back to section top

### class DefaultRunner(SchemaVisitor)

A visitor which accepts ColumnDefault objects, produces the dialect-specific SQL corresponding to their execution, and executes the SQL, returning the result value.

DefaultRunners are used internally by Engines and Dialects. Specific database modules should provide their own subclasses of DefaultRunner to allow database-specific behavior.

def __init__(self, context)

Construct a new `DefaultRunner`.

def exec_default_sql(self, default)
def execute_string(self, stmt, params=None)

execute a string statement, using the raw cursor, and return a scalar result.

def get_column_default(self, column)
def get_column_onupdate(self, column)
def visit_column_default(self, default)
def visit_column_onupdate(self, onupdate)
def visit_passive_default(self, default)

Do nothing.

Passive defaults by definition return None on the app side, and are post-fetched to get the DB-side value.

def visit_sequence(self, seq)

Do nothing.

back to section top

### class Dialect(object)

Define the behavior of a specific database and DB-API combination.

Any aspect of metadata definition, SQL query generation, execution, result-set handling, or anything else which varies between databases is defined under the general category of the Dialect. The Dialect acts as a factory for other database-specific object implementations including ExecutionContext, Compiled, DefaultGenerator, and TypeEngine.

All Dialects implement the following attributes:

positional
  True if the paramstyle for this Dialect is positional.
paramstyle
  the paramstyle to be used (some DB-APIs support multiple paramstyles).
convert_unicode
  True if Unicode conversion should be applied to all `str` types.
encoding
  type of encoding to use for unicode, usually defaults to 'utf-8'.
schemagenerator
  a SchemaVisitor class which generates schemas.
schemadropper
  a SchemaVisitor class which drops schemas.
defaultrunner
  a SchemaVisitor class which executes defaults.
statement_compiler
  a Compiled class used to compile SQL statements
preparer
  a IdentifierPreparer class used to quote identifiers.
supports_alter
  `True` if the database supports `ALTER TABLE`.
max_identifier_length
  The maximum length of identifier names.
supports_unicode_statements
  Indicate whether the DB-API can receive SQL statements as Python unicode strings
supports_sane_rowcount
  Indicate whether the dialect properly implements rowcount for `UPDATE` and `DELETE` statements.
supports_sane_multi_rowcount
  Indicate whether the dialect properly implements rowcount for `UPDATE` and `DELETE` statements when executed via executemany.
preexecute_pk_sequences
  Indicate if the dialect should pre-execute sequences on primary key columns during an INSERT, if it's desired that the new row's primary key be available after execution.
supports_pk_autoincrement
  Indicates if the dialect should allow the database to passively assign a primary key column value.
dbapi_type_map

  A mapping of DB-API type objects present in this Dialect's DB-API implmentation mapped to TypeEngine implementations used by the dialect.

  This is used to apply types to result sets based on the DB-API types present in cursor.description; it only takes effect for result sets against textual statements where no explicit typemap was present.

def create_connect_args(self, url)

Build DB-API compatible connection arguments.

Given a URL object, returns a tuple consisting of a *args/**kwargs suitable to send directly to the dbapi's connect function.

def create_execution_context(self, connection, compiled=None, compiled_parameters=None, statement=None, parameters=None)

Return a new ExecutionContext object.

def create_xid(self)

Create a two-phase transaction ID.

This id will be passed to do_begin_twophase(), do_rollback_twophase(), do_commit_twophase(). Its format is unspecified.

def do_begin(self, connection)

Provide an implementation of connection.begin(), given a DB-API connection.

def do_begin_twophase(self, connection, xid)

Begin a two phase transaction on the given connection.

def do_commit(self, connection)

Provide an implementation of connection.commit(), given a DB-API connection.

def do_commit_twophase(self, connection, xid, is_prepared=True, recover=False)

Commit a two phase transaction on the given connection.

def do_execute(self, cursor, statement, parameters, context=None)

Provide an implementation of cursor.execute(statement, parameters).

def do_executemany(self, cursor, statement, parameters, context=None)

Provide an implementation of cursor.executemany(statement, parameters).

def do_prepare_twophase(self, connection, xid)

Prepare a two phase transaction on the given connection.

def do_recover_twophase(self, connection)

Recover list of uncommited prepared two phase transaction identifiers on the given connection.

def do_release_savepoint(self, connection, name)

Release the named savepoint on a SQL Alchemy connection.

def do_rollback(self, connection)

Provide an implementation of connection.rollback(), given a DB-API connection.

def do_rollback_to_savepoint(self, connection, name)

Rollback a SQL Alchemy connection to the named savepoint.

def do_rollback_twophase(self, connection, xid, is_prepared=True, recover=False)

Rollback a two phase transaction on the given connection.

def do_savepoint(self, connection, name)

Create a savepoint with the given name on a SQLAlchemy connection.

def get_default_schema_name(self, connection)

Return the string name of the currently selected schema given a Connection.

def has_sequence(self, connection, sequence_name)

Check the existence of a particular sequence in the database.

Given a Connection object and a string sequence_name, return True if the given sequence exists in the database, False otherwise.

def has_table(self, connection, table_name, schema=None)

Check the existence of a particular table in the database.

Given a Connection object and a string table_name, return True if the given table (possibly within the specified schema) exists in the database, False otherwise.

def is_disconnect(self, e)

Return True if the given DB-API error indicates an invalid connection

def oid_column_name(self, column)

Return the oid column name for this Dialect

May return `None` if the dialect can't o won't support OID/ROWID features.

The Column instance which represents OID for the query being compiled is passed, so that the dialect can inspect the column and its parent selectable to determine if OID/ROWID is not selected for a particular selectable (i.e. Oracle doesnt support ROWID for UNION, GROUP BY, DISTINCT, etc.)

def reflecttable(self, connection, table, include_columns=None)

Load table description from the database.

Given a Connection and a Table object, reflect its columns and properties from the database. If include_columns (a list or set) is specified, limit the autoload to the given column names.

def server_version_info(self, connection)

Return a tuple of the database's version number.

def type_descriptor(self, typeobj)

Transform a generic type to a database-specific type.

Transforms the given TypeEngine instance from generic to database-specific.

Subclasses will usually use the adapt_type() method in the types module to make this job easy.

back to section top

### class Engine(Connectable)

Connects a Pool, a Dialect and a CompilerFactory together to provide a default implementation of SchemaEngine.

def __init__(self, pool, dialect, url, echo=None)

Construct a new `Engine`.

def connect(self, **kwargs)

Return a newly allocated Connection object.

def contextual_connect(self, close_with_result=False, **kwargs)

Return a Connection object which may be newly allocated, or may be part of some ongoing context.

This Connection is meant to be used by the various "auto-connecting" operations.

def create(self, entity, connection=None, **kwargs)

Create a table or index within this engine's database connection given a schema.Table object.

def dispose(self)
def drop(self, entity, connection=None, **kwargs)

Drop a table or index within this engine's database connection given a schema.Table object.

echo = property()

When `True`, enable log output for this element.

This has the effect of setting the Python logging level for the namespace of this element's class and object reference. A value of boolean `True` indicates that the loglevel `logging.INFO` will be set for the logger, whereas the string value `debug` will set the loglevel to `logging.DEBUG`.

def execute(self, statement, *multiparams, **params)
def execute_clauseelement(self, elem, multiparams=None, params=None)
func = property()
def has_table(self, table_name, schema=None)
name = property()

String name of the Dialect in use by this `Engine`.

def raw_connection(self)

Return a DB-API connection.

def reflecttable(self, table, connection=None, include_columns=None)

Given a Table object, reflects its columns and properties from the database.

def run_callable(self, callable_, connection=None, *args, **kwargs)
def scalar(self, statement, *multiparams, **params)
def statement_compiler(self, statement, **kwargs)
def table_names(self, schema=None, connection=None)

Return a list of all table names available in the database.

schema:
  Optional, retrieve names from a non-default schema.
connection:
  Optional, use a specified connection. Default is the `contextual_connect` for this `Engine`.

def text(self, text, *args, **kwargs)

Return a sql.text() object for performing literal queries.

def transaction(self, callable_, connection=None, *args, **kwargs)

Execute the given function within a transaction boundary.

This is a shortcut for explicitly calling begin() and commit() and optionally rollback() when exceptions are raised. The given *args and **kwargs will be passed to the function, as well as the Connection used in the transaction.

back to section top

### class ExecutionContext(object)

A messenger object for a Dialect that corresponds to a single execution.

ExecutionContext should have these datamembers:

connection
  Connection object which can be freely used by default value generators to execute SQL. This Connection should reference the same underlying connection/transactional resources of root_connection.
root_connection
  Connection object which is the source of this ExecutionContext. This Connection may have close_with_result=True set, in which case it can only be used once.
dialect
  dialect which created this ExecutionContext.
cursor
  DB-API cursor procured from the connection,
compiled
  if passed to constructor, sqlalchemy.engine.base.Compiled object being executed,
statement
  string version of the statement to be executed. Is either passed to the constructor, or must be created from the sql.Compiled object by the time pre_exec() has completed.
parameters
  bind parameters passed to the execute() method. For compiled statements, this is a dictionary or list of dictionaries. For textual statements, it should be in a format suitable for the dialect's paramstyle (i.e. dict or list of dicts for non positional, list or list of lists/tuples for positional).
isinsert
  True if the statement is an INSERT.
isupdate
  True if the statement is an UPDATE.
should_autocommit
  True if the statement is a "committable" statement
returns_rows
  True if the statement should return result rows
postfetch_cols
  a list of Column objects for which a server-side default or inline SQL expression value was fired off. applies to inserts and updates.

The Dialect should provide an ExecutionContext via the create_execution_context() method. The pre_exec and post_exec methods will be called for compiled statements.

def create_cursor(self)

Return a new cursor generated from this ExecutionContext's connection.

Some dialects may wish to change the behavior of connection.cursor(), such as postgres which may return a PG "server side" cursor.

def get_rowcount(self)

Return the count of rows updated/deleted for an UPDATE/DELETE statement.

def last_inserted_ids(self)

Return the list of the primary key values for the last insert statement executed.

This does not apply to straight textual clauses; only to `sql.Insert` objects compiled against a `schema.Table` object. The order of items in the list is the same as that of the Table's 'primary_key' attribute.

def last_inserted_params(self)

Return a dictionary of the full parameter dictionary for the last compiled INSERT statement.

Includes any ColumnDefaults or Sequences that were pre-executed.

def last_updated_params(self)

Return a dictionary of the full parameter dictionary for the last compiled UPDATE statement.

Includes any ColumnDefaults that were pre-executed.

def lastrow_has_defaults(self)

Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.

def post_execution(self)

Called after the execution of a compiled statement.

If a compiled statement was passed to this ExecutionContext, the last_insert_ids, last_inserted_params, etc. datamembers should be available after this method completes.

def pre_execution(self)

Called before an execution of a compiled statement.

If a compiled statement was passed to this ExecutionContext, the statement and parameters datamembers must be initialized after this statement is complete.

def result(self)

Return a result object corresponding to this ExecutionContext.

Returns a ResultProxy.

def should_autocommit_compiled(self, compiled)

return True if the given Compiled object refers to a "committable" statement.

def should_autocommit_text(self, statement)

Parse the given textual statement and return True if it refers to a "committable" statement

back to section top

### class NestedTransaction(Transaction)

def __init__(self, connection, parent)

Construct a new `NestedTransaction`.

back to section top

### class ResultProxy(object)

Wraps a DB-API cursor object to provide easier access to row columns.

Individual columns may be accessed by their integer position, case-insensitive column name, or by `schema.Column` object. e.g.:

    row = fetchone()

    col1 = row[0]    # access via integer position

    col2 = row['col2']   # access via name

    col3 = row[mytable.c.mycol] # access via Column object.

ResultProxy also contains a map of TypeEngine objects and will invoke the appropriate `result_processor()` method before returning columns, as well as the ExecutionContext corresponding to the statement execution. It provides several methods for which to obtain information from the underlying ExecutionContext.

def __init__(self, context)

ResultProxy objects are constructed via the execute() method on SQLEngine.

def close(self)

Close this ResultProxy, and the underlying DB-API cursor corresponding to the execution.

If this ResultProxy was generated from an implicit execution, the underlying Connection will also be closed (returns the underlying DB-API connection to the connection pool.)

This method is also called automatically when all result rows are exhausted.

def fetchall(self)

Fetch all rows, just like DB-API `cursor.fetchall()`.

def fetchmany(self, size=None)

Fetch many rows, just like DB-API `cursor.fetchmany(size=cursor.arraysize)`.

def fetchone(self)

Fetch one row, just like DB-API `cursor.fetchone()`.

keys = property()
def last_inserted_ids(self)

Return `last_inserted_ids()` from the underlying ExecutionContext.

See ExecutionContext for details.

def last_inserted_params(self)

Return `last_inserted_params()` from the underlying ExecutionContext.

See ExecutionContext for details.

def last_updated_params(self)

Return `last_updated_params()` from the underlying ExecutionContext.

See ExecutionContext for details.

def lastrow_has_defaults(self)

Return `lastrow_has_defaults()` from the underlying ExecutionContext.

See ExecutionContext for details.

lastrowid = property()
out_parameters = property()
def postfetch_cols(self)

Return `postfetch_cols()` from the underlying ExecutionContext.

See ExecutionContext for details.

rowcount = property()
def scalar(self)

Fetch the first column of the first row, and close the result set.

def supports_sane_multi_rowcount(self)

Return `supports_sane_multi_rowcount` from the dialect.

def supports_sane_rowcount(self)

Return `supports_sane_rowcount` from the dialect.

def __iter__(self)
back to section top

### class RootTransaction(Transaction)

def __init__(self, connection)

Construct a new `RootTransaction`.

back to section top

### class RowProxy(object)

Proxy a single cursor row for a parent ResultProxy.

Mostly follows "ordered dictionary" behavior, mapping result values to the string-based column name, the integer position of the result in the row, as well as Column instances which can be mapped to the original Columns that produced this result set (for results that correspond to constructed SQL expressions).

def __init__(self, parent, row)

RowProxy objects are constructed by ResultProxy objects.

def close(self)

Close the parent ResultProxy.

def has_key(self, key)

Return True if this RowProxy contains the given key.

def items(self)

Return a list of tuples, each tuple containing a key/value pair.

def keys(self)

Return the list of keys as strings represented by this RowProxy.

def values(self)

Return the values represented by this RowProxy as a list.

def __contains__(self, key)
def __eq__(self, other)
def __getattr__(self, name)
def __getitem__(self, key)
def __iter__(self)
def __len__(self)
def __ne__(self, other)
back to section top

### class SchemaIterator(SchemaVisitor)

A visitor that can gather text into a buffer and execute the contents of the buffer.

def __init__(self, connection)

Construct a new SchemaIterator.

def append(self, s)

Append content to the SchemaIterator's query buffer.

def execute(self)

Execute the contents of the SchemaIterator's buffer.

back to section top

### class Transaction(object)

Represent a Transaction in progress.

The Transaction object is not threadsafe.

def __init__(self, connection, parent)

Construct a new `Transaction`.

def close(self)

Close this 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.

def commit(self)
connection = property()

The Connection object referenced by this Transaction

is_active = property()
def rollback(self)
def __enter__(self)
def __exit__(self, type, value, traceback)
back to section top

### class TwoPhaseTransaction(Transaction)

def __init__(self, connection, xid)

Construct a new `TwoPhaseTransaction`.

def commit(self)
def prepare(self)
back to section top