SQLAlchemy 0.3 Documentation - module sqlalchemy.ansisql

# SQLAlchemy 0.3 Documentation

Multiple Pages | One Page
Version: 0.3.7 Last Updated: 04/30/07 00:08:52

### module sqlalchemy.ansisql

Defines ANSI SQL operations.

Contains default implementations for the abstract objects in the sql module.

### class ANSICompiler(Compiled)

Default implementation of Compiled.

Compiles ClauseElements into ANSI-compliant SQL strings.

def __init__(self, dialect, statement, parameters=None, **kwargs)

Construct a new `ANSICompiler` object.

dialect
  Dialect to be used
statement
  ClauseElement to be compiled
parameters
  optional dictionary indicating a set of bind parameters specified with this Compiled object. These parameters are the default key/value pairs when the Compiled is executed, and also may affect the actual compilation, as in the case of an INSERT where the actual columns inserted will correspond to the keys present in the parameters.

def after_compile(self)
def apply_function_parens(self, func)
def binary_operator_string(self, binary)
def bindparam_string(self, name)
def construct_params(self, params)

Return a structure of bind parameters for this compiled object.

This includes bind parameters that might be compiled in via the values argument of an `Insert` or `Update` statement object, and also the given **params. The keys inside of **params can be any key that matches the `BindParameterClause` objects compiled within this object.

The output is dependent on the paramstyle of the DBAPI being used; if a named style, the return result will be a dictionary with keynames matching the compiled statement. If a positional style, the output will be a list, with an iterator that will return parameter values in an order corresponding to the bind positions in the compiled statement.

For an executemany style of call, this method should be called for each element in the list of parameter groups that will ultimately be executed.

def default_from(self)

Called when a SELECT statement has no froms, and no FROM clause is to be appended.

Gives Oracle a chance to tack on a `FROM DUAL` to the string output.

def for_update_clause(self, select)
def get_from_text(self, obj)
def get_str(self, obj)
def get_whereclause(self, obj)
def limit_clause(self, select)
def order_by_clause(self, select)
def visit_alias(self, alias)
def visit_binary(self, binary)
def visit_bindparam(self, bindparam)
def visit_calculatedclause(self, list)
def visit_cast(self, cast)
def visit_clauselist(self, list)
def visit_column(self, column)
def visit_compound(self, compound)
def visit_compound_select(self, cs)
def visit_delete(self, delete_stmt)
def visit_fromclause(self, fromclause)
def visit_function(self, func)
def visit_index(self, index)
def visit_insert(self, insert_stmt)
def visit_insert_column(self, column, parameters)

Called when visiting an `Insert` statement.

This may be overridden by compilers who disallow NULL columns being set in an `Insert` where there is a default value on the column (i.e. postgres), to remove the column for which there is a NULL insert from the parameter list.

def visit_insert_column_default(self, column, default, parameters)

Called when visiting an `Insert` statement.

For each column in the table that contains a `ColumnDefault` object, add a blank placeholder parameter so the `Insert` gets compiled with this column's name in its column and `VALUES` clauses.

def visit_insert_sequence(self, column, sequence, parameters)

Called when visiting an `Insert` statement.

This may be overridden compilers that support sequences to place a blank placeholder parameter for each column in the table that contains a Sequence object, so the Insert gets compiled with this column's name in its column and `VALUES` clauses.

def visit_join(self, join)
def visit_label(self, label)
def visit_null(self, null)
def visit_select(self, select)
def visit_select_postclauses(self, select)

Called when building a `SELECT` statement, position is after all other `SELECT` clauses.

Most DB syntaxes put `LIMIT`/`OFFSET` here.

def visit_select_precolumns(self, select)

Called when building a `SELECT` statement, position is just before column list.

def visit_table(self, table)
def visit_textclause(self, textclause)
def visit_typeclause(self, typeclause)
def visit_update(self, update_stmt)
def visit_update_column_default(self, column, default, parameters)

Called when visiting an `Update` statement.

For each column in the table that contains a `ColumnDefault` object as an onupdate, add a blank placeholder parameter so the `Update` gets compiled with this column's name as one of its `SET` clauses.

back to section top

### class ANSIDefaultRunner(DefaultRunner)

back to section top

### class ANSIDialect(DefaultDialect)

def __init__(self, cache_identifiers=True, **kwargs)
def compiler(self, statement, parameters, **kwargs)
def create_connect_args(self)
def preparer(self)

Return an IdentifierPreparer.

This object is used to format table and column names including proper quoting and case conventions.

def schemadropper(self, *args, **kwargs)
def schemagenerator(self, *args, **kwargs)
back to section top

### class ANSIIdentifierPreparer(object)

Handle quoting and case-folding of identifiers based on options.

def __init__(self, dialect, initial_quote='"', final_quote=None, omit_schema=False)

Construct a new `ANSIIdentifierPreparer` object.

initial_quote
  Character that begins a delimited identifier.
final_quote
  Character that ends a delimited identifier. Defaults to initial_quote.
omit_schema
  Prevent prepending schema name. Useful for databases that do not support schemae.

def format_alias(self, alias)
def format_column(self, column, use_table=False, name=None)

Prepare a quoted column name.

def format_column_with_table(self, column, column_name=None)

Prepare a quoted column name with table name.

def format_label(self, label, name=None)
def format_sequence(self, sequence)
def format_table(self, table, use_schema=True, name=None)

Prepare a quoted table and schema name.

def is_natural_case(self, object)
def should_quote(self, object)
back to section top

### class ANSISchemaBase(SchemaIterator)

def find_alterables(self, tables)
back to section top

### class ANSISchemaDropper(ANSISchemaBase)

def __init__(self, dialect, connection, checkfirst=False, tables=None, **kwargs)
def drop_foreignkey(self, constraint)
def visit_index(self, index)
def visit_metadata(self, metadata)
def visit_table(self, table)
back to section top

### class ANSISchemaGenerator(ANSISchemaBase)

def __init__(self, dialect, connection, checkfirst=False, tables=None, **kwargs)
def add_foreignkey(self, constraint)
def define_foreign_key(self, constraint)
def get_column_default_string(self, column)
def get_column_specification(self, column, first_pk=False)
def post_create_table(self, table)
def visit_check_constraint(self, constraint)
def visit_column(self, column)
def visit_column_check_constraint(self, constraint)
def visit_foreign_key_constraint(self, constraint)
def visit_index(self, index)
def visit_metadata(self, metadata)
def visit_primary_key_constraint(self, constraint)
def visit_table(self, table)
def visit_unique_constraint(self, constraint)
back to section top