Some key internal constructs are listed here.
Bases: object
Represent a compiled SQL or DDL 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.
Construct a new Compiled object.
Parameters: |
|
---|
Produce the internal string representation of this element.
Deprecated since version 0.7: Compiled objects now compile within the constructor.
Return the bind params for this compiled object.
Parameters: | params – a dict of string/object pairs whos values will override bind values compiled in to the statement. |
---|
Execute this compiled object.
Return the bind params for this compiled object.
Execute this compiled object and return the result’s scalar value.
Return a Compiled that is capable of processing SQL expressions.
If this compiler is one, it would likely just return ‘self’.
Bases: sqlalchemy.engine.base.Compiled
Format the remote table clause of a CREATE CONSTRAINT clause.
Bases: sqlalchemy.engine.base.Dialect
Default implementation of Dialect
Create a random two-phase transaction ID.
This id will be passed to do_begin_twophase(), do_rollback_twophase(), do_commit_twophase(). Its format is unspecified.
alias of DDLCompiler
Implementations might want to put logic here for turning autocommit on/off, etc.
Implementations might want to put logic here for turning autocommit on/off, etc.
Implementations might want to put logic here for turning autocommit on/off, etc.
alias of tuple
alias of DefaultExecutionContext
Compatiblity method, adapts the result of get_primary_keys() for those dialects which don’t implement get_pk_constraint().
return a callable which sets up a newly created DBAPI connection.
This is used to set dialect-wide per-connection options such as isolation modes, unicode modes, etc.
If a callable is returned, it will be assembled into a pool listener that receives the direct DBAPI connection, with all wrappers removed.
If None is returned, no listener will be generated.
alias of IdentifierPreparer
alias of SQLCompiler
alias of GenericTypeCompiler
Provide a database-specific TypeEngine object, given the generic object which comes from the types module.
This method looks for a dictionary called colspecs as a class or instance-level variable, and passes on to types.adapt_type().
Bases: 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:
A mapping of DB-API type objects present in this Dialect’s DB-API implementation 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.
return a callable which sets up a newly created DBAPI connection.
The callable accepts a single argument “conn” which is the DBAPI connection itself. It has no return value.
This is used to set dialect-wide per-connection options such as isolation modes, unicode modes, etc.
If a callable is returned, it will be assembled into a pool listener that receives the direct DBAPI connection, with all wrappers removed.
If None is returned, no listener will be generated.
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.
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.
convert the given name to a case insensitive identifier for the backend if it is an all-lowercase name.
this method is only used if the dialect defines requires_name_normalize=True.
Provide an implementation of connection.begin(), given a DB-API connection.
Begin a two phase transaction on the given connection.
Provide an implementation of connection.commit(), given a DB-API connection.
Commit a two phase transaction on the given connection.
Provide an implementation of cursor.execute(statement, parameters).
Provide an implementation of cursor.executemany(statement, parameters).
Prepare a two phase transaction on the given connection.
Recover list of uncommited prepared two phase transaction identifiers on the given connection.
Release the named savepoint on a SQL Alchemy connection.
Provide an implementation of connection.rollback(), given a DB-API connection.
Rollback a SQL Alchemy connection to the named savepoint.
Rollback a two phase transaction on the given connection.
Create a savepoint with the given name on a SQLAlchemy connection.
Return information about columns in table_name.
Given a Connection, a string table_name, and an optional string schema, return column information as a list of dictionaries with these keys:
Additional column attributes may be present.
Return information about foreign_keys in table_name.
Given a Connection, a string table_name, and an optional string schema, return foreign key information as a list of dicts with these keys:
Return information about indexes in table_name.
Given a Connection, a string table_name and an optional string schema, return index information as a list of dictionaries with these keys:
Given a DBAPI connection, return its isolation level.
Return information about the primary key constraint on table_name`.
Given a string table_name, and an optional string schema, return primary key information as a dictionary with these keys:
Return information about primary keys in table_name.
Given a Connection, a string table_name, and an optional string schema, return primary key information as a list of column names.
Return a list of table names for schema.
Return view definition.
Given a Connection, a string view_name, and an optional string schema, return the view definition.
Return a list of all view names available in the database.
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.
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.
Called during strategized creation of the dialect with a connection.
Allows dialects to configure options based on server version info or other properties.
The connection passed here is a SQLAlchemy Connection object, with full capabilities.
The initalize() method of the base dialect should be called via super().
Return True if the given DB-API error indicates an invalid connection
convert the given name to lowercase if it is detected as case insensitive.
this method is only used if the dialect defines requires_name_normalize=True.
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.
The default implementation uses the Inspector interface to provide the output, building upon the granular table/column/ constraint etc. methods of Dialect.
Given a DBAPI connection, revert its isolation to the default.
Given a DBAPI connection, set its isolation level.
Transform a generic type to a dialect-specific type.
Dialect classes will usually use the adapt_type() function in the types module to make this job easy.
The returned result is cached per dialect class so can contain no dialect-instance state.
Bases: sqlalchemy.engine.base.ExecutionContext
return self.cursor.lastrowid, or equivalent, after an INSERT.
This may involve calling special cursor functions, issuing a new SELECT on the cursor (or a new one), or returning a stored value that was calculated within post_exec().
This function will only be called for dialects which support “implicit” primary key generation, keep preexecute_autoincrement_sequences set to False, and when no explicit id value was bound to the statement.
The function is called once, directly after post_exec() and before the transaction is committed or ResultProxy is generated. If the post_exec() method assigns a value to self._lastrowid, the value is used in place of calling get_lastrowid().
Note that this method is not equivalent to the lastrowid method on ResultProxy, which is a direct proxy to the DBAPI lastrowid accessor in all cases.
Given a cursor and ClauseParameters, call the appropriate style of setinputsizes() on the cursor, using DB-API types from the bind parameter’s TypeEngine objects.
This method only called by those dialects which require it, currently cx_oracle.
Bases: object
A messenger object for a Dialect that corresponds to a single execution.
ExecutionContext should have these data members:
Return a new cursor generated from this ExecutionContext’s connection.
Some dialects may wish to change the behavior of connection.cursor(), such as postgresql which may return a PG “server side” cursor.
Return the number of rows produced (by a SELECT query) or affected (by an INSERT/UPDATE/DELETE statement).
Note that this row count may not be properly implemented in some dialects; this is indicated by the supports_sane_rowcount and supports_sane_multi_rowcount dialect attributes.
Receive a DBAPI exception which occurred upon execute, result fetch, etc.
Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
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.
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.
Return a result object corresponding to this ExecutionContext.
Returns a ResultProxy.
Parse the given textual statement and return True if it refers to a “committable” statement
Bases: object
Handle quoting and case-folding of identifiers based on options.
Construct a new IdentifierPreparer object.
Prepare a quoted column name.
Prepare a quoted table and schema name.
Format table name and schema as a tuple.
Quote an identifier.
Subclasses should override this to provide database-dependent quoting behavior.
Quote a schema.
Subclasses should override this to provide database-dependent quoting behavior.
Unpack ‘schema.table.column’-like strings into components.
Bases: sqlalchemy.engine.base.Compiled
Default implementation of Compiled.
Compiles ClauseElements into SQL strings. Uses a similar visit paradigm as visitors.ClauseVisitor but implements its own traversal.
Construct a new DefaultCompiler object.
return a dictionary of bind parameter keys and values
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.
provide escaping for the literal_column() construct.
Called when building a SELECT statement, position is just before column list.
label columns present in a select().
Return the bind params for this compiled object.
Render the value of a bind parameter as a quoted literal.
This is used for statement sections that do not accept bind paramters on the target driver/database.
This should be implemented by subclasses using the quoting services of the DBAPI.