class documentation

class DefaultExecutionContext(interfaces.ExecutionContext):

Known subclasses: sqlalchemy.databases.firebird.FBExecutionContext, sqlalchemy.databases.mssql.MSExecutionContext, sqlalchemy.databases.mysql.MySQLExecutionContext, sqlalchemy.databases.oracle.OracleExecutionContext, sqlalchemy.databases.postgresql.PGExecutionContext, sqlalchemy.databases.sqlite.SQLiteExecutionContext, sqlalchemy.databases.sybase.SybaseExecutionContext

View In Hierarchy

Undocumented

Method create​_cursor Return a new cursor generated from this ExecutionContext's connection.
Method get​_current​_parameters Return a dictionary of parameters applied to the current row.
Method get​_lastrowid return self.cursor.lastrowid, or equivalent, after an INSERT.
Method get​_out​_parameter​_values Return a sequence of OUT parameter values from a cursor.
Method get​_result​_processor Return a 'result processor' for a given type as present in cursor.description.
Method handle​_dbapi​_exception Receive a DBAPI exception which occurred upon execute, result fetch, etc.
Method lastrow​_has​_defaults Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
Method post​_exec Called after the execution of a compiled statement.
Method pre​_exec Called before an execution of a compiled statement.
Method should​_autocommit​_text Parse the given textual statement and return True if it refers to a "committable" statement
Instance Variable current​_parameters A dictionary of parameters applied to the current row.
Class Method ​_init​_compiled Initialize execution context for a Compiled construct.
Class Method ​_init​_ddl Initialize execution context for a DDLElement construct.
Class Method ​_init​_default Initialize execution context for a ColumnDefault construct.
Class Method ​_init​_statement Initialize execution context for a string SQL statement.
Method ​_exec​_default Undocumented
Method ​_exec​_default​_clause​_element Undocumented
Method ​_execute​_scalar Execute a string statement on the current cursor, returning a scalar result.
Method ​_get​_cache​_stats Undocumented
Method ​_process​_executemany​_defaults Undocumented
Method ​_process​_executesingle​_defaults Undocumented
Method ​_set​_input​_sizes 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.
Method ​_setup​_dml​_or​_text​_result Undocumented
Method ​_setup​_ins​_pk​_from​_empty Undocumented
Method ​_setup​_ins​_pk​_from​_implicit​_returning Undocumented
Method ​_setup​_ins​_pk​_from​_lastrowid Undocumented
Method ​_setup​_out​_parameters Undocumented
Method ​_setup​_result​_proxy Undocumented
Method ​_use​_server​_side​_cursor Undocumented
Method create​_default​_cursor Undocumented
Method create​_server​_side​_cursor Undocumented
Method get​_insert​_default Undocumented
Method get​_update​_default Undocumented
Method supports​_sane​_multi​_rowcount Undocumented
Method supports​_sane​_rowcount Undocumented
Class Variable ​_translate​_colname Undocumented
Class Variable cache​_stats Undocumented
Class Variable exclude​_set​_input​_sizes Undocumented
Class Variable include​_set​_input​_sizes Undocumented
Instance Variable ​_dbapi​_connection Undocumented
Instance Variable ​_expanded​_parameters Undocumented
Instance Variable ​_is​_explicit​_returning Undocumented
Instance Variable ​_is​_future​_result Undocumented
Instance Variable ​_is​_implicit​_returning Undocumented
Instance Variable ​_is​_server​_side Undocumented
Instance Variable ​_soft​_closed Undocumented
Instance Variable cache​_hit Undocumented
Instance Variable compiled Undocumented
Instance Variable compiled​_parameters Undocumented
Instance Variable cursor Undocumented
Instance Variable dialect Undocumented
Instance Variable executemany Undocumented
Instance Variable execution​_options Undocumented
Instance Variable extracted​_parameters Undocumented
Instance Variable invoked​_statement Undocumented
Instance Variable is​_crud Undocumented
Instance Variable is​_text Undocumented
Instance Variable isddl Undocumented
Instance Variable isdelete Undocumented
Instance Variable isinsert Undocumented
Instance Variable isupdate Undocumented
Instance Variable parameters Undocumented
Instance Variable result​_column​_struct Undocumented
Instance Variable returned​_default​_rows Undocumented
Instance Variable root​_connection Undocumented
Instance Variable statement Undocumented
Instance Variable unicode​_statement Undocumented
Property connection Undocumented
Property engine Undocumented
Property identifier​_preparer Undocumented
Property inserted​_primary​_key​_rows Undocumented
Property no​_parameters Undocumented
Property postfetch​_cols Undocumented
Property prefetch​_cols Undocumented
Property returning​_cols Undocumented
Property rowcount Undocumented
Property should​_autocommit Undocumented

Inherited from ExecutionContext:

Method get​_result​_cursor​_strategy Return a result cursor strategy for a given result object.
Method get​_rowcount Return the DBAPI cursor.rowcount value, or in some cases an interpreted value.
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 postgresql which may return a PG "server side" cursor.

def get_current_parameters(self, isolate_multiinsert_groups=True):

Return a dictionary of parameters applied to the current row.

This method can only be used in the context of a user-defined default generation function, e.g. as described at :ref:`context_default_functions`. When invoked, a dictionary is returned which includes entries for each column/value pair that is part of the INSERT or UPDATE statement. The keys of the dictionary will be the key value of each _schema.Column, which is usually synonymous with the name.

New in version 1.2: added .DefaultExecutionContext.get_current_parameters which provides more functionality over the existing .DefaultExecutionContext.current_parameters attribute.

See Also

.DefaultExecutionContext.current_parameters

:ref:`context_default_functions`

Parameters
isolate​_multiinsert​_groupsUndocumented
isolate_multiinsert_groups=​Trueindicates that multi-valued INSERT constructs created using _expression.Insert.values should be handled by returning only the subset of parameters that are local to the current column default invocation. When False, the raw parameters of the statement are returned including the naming convention used in the case of multi-valued INSERT.
def get_lastrowid(self):

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 for an INSERT statement that would need to return the last inserted primary key for those dialects that make use of the lastrowid concept. In these cases, it is called directly after .ExecutionContext.post_exec.

def get_out_parameter_values(self, names):

Return a sequence of OUT parameter values from a cursor.

For dialects that support OUT parameters, this method will be called when there is a .SQLCompiler object which has the .SQLCompiler.has_out_parameters flag set. This flag in turn will be set to True if the statement itself has .BindParameter objects that have the .isoutparam flag set which are consumed by the .SQLCompiler.visit_bindparam method. If the dialect compiler produces .BindParameter objects with .isoutparam set which are not handled by .SQLCompiler.visit_bindparam, it should set this flag explicitly.

The list of names that were rendered for each bound parameter is passed to the method. The method should then return a sequence of values corresponding to the list of parameter objects. Unlike in previous SQLAlchemy versions, the values can be the raw values from the DBAPI; the execution context will apply the appropriate type handler based on what's present in self.compiled.binds and update the values. The processed dictionary will then be made available via the .out_parameters collection on the result object. Note that SQLAlchemy 1.4 has multiple kinds of result object as part of the 2.0 transition.

New in version 1.4: - added .ExecutionContext.get_out_parameter_values, which is invoked automatically by the .DefaultExecutionContext when there are .BindParameter objects with the .isoutparam flag set. This replaces the practice of setting out parameters within the now-removed get_result_proxy() method.

See Also

.ExecutionContext.get_result_cursor_strategy

def get_result_processor(self, type_, colname, coltype):

Return a 'result processor' for a given type as present in cursor.description.

This has a default implementation that dialects can override for context-sensitive result type handling.

def handle_dbapi_exception(self, e):
def lastrow_has_defaults(self):
Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
def post_exec(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 should_autocommit_text(self, statement):
Parse the given textual statement and return True if it refers to a "committable" statement
current_parameters =

A dictionary of parameters applied to the current row.

This attribute is only available in the context of a user-defined default generation function, e.g. as described at :ref:`context_default_functions`. It consists of a dictionary which includes entries for each column/value pair that is to be part of the INSERT or UPDATE statement. The keys of the dictionary will be the key value of each _schema.Column, which is usually synonymous with the name.

Note that the .DefaultExecutionContext.current_parameters attribute does not accommodate for the "multi-values" feature of the _expression.Insert.values method. The .DefaultExecutionContext.get_current_parameters method should be preferred.

See Also

.DefaultExecutionContext.get_current_parameters

:ref:`context_default_functions`

@classmethod
def _init_compiled(cls, dialect, connection, dbapi_connection, execution_options, compiled, parameters, invoked_statement, extracted_parameters, cache_hit=CACHING_DISABLED):
Initialize execution context for a Compiled construct.
@classmethod
def _init_ddl(cls, dialect, connection, dbapi_connection, execution_options, compiled_ddl):
Initialize execution context for a DDLElement construct.
@classmethod
def _init_default(cls, dialect, connection, dbapi_connection, execution_options):
Initialize execution context for a ColumnDefault construct.
@classmethod
def _init_statement(cls, dialect, connection, dbapi_connection, execution_options, statement, parameters):
Initialize execution context for a string SQL statement.
def _exec_default(self, column, default, type_):

Undocumented

def _exec_default_clause_element(self, column, default, type_):

Undocumented

def _execute_scalar(self, stmt, type_, parameters=None):

Execute a string statement on the current cursor, returning a scalar result.

Used to fire off sequences, default phrases, and "select lastrowid" types of statements individually or in the context of a parent INSERT or UPDATE statement.

def _get_cache_stats(self):

Undocumented

def _process_executemany_defaults(self):

Undocumented

def _process_executesingle_defaults(self):

Undocumented

def _set_input_sizes(self):

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, asyncpg and pg8000.

def _setup_dml_or_text_result(self):

Undocumented

def _setup_ins_pk_from_empty(self):

Undocumented

def _setup_ins_pk_from_implicit_returning(self, result, rows):

Undocumented

def _setup_ins_pk_from_lastrowid(self):

Undocumented

def _setup_out_parameters(self, result):

Undocumented

def _setup_result_proxy(self):

Undocumented

def _use_server_side_cursor(self):

Undocumented

def create_default_cursor(self):
def get_insert_default(self, column):
def get_update_default(self, column):

Undocumented

def supports_sane_multi_rowcount(self):

Undocumented

def supports_sane_rowcount(self):

Undocumented

_translate_colname =
cache_stats =

Undocumented

exclude_set_input_sizes =
include_set_input_sizes =
_dbapi_connection =

Undocumented

_expanded_parameters =

Undocumented

_is_explicit_returning =

Undocumented

_is_future_result =

Undocumented

_is_implicit_returning =

Undocumented

_is_server_side: bool =

Undocumented

_soft_closed =

Undocumented

cache_hit =

Undocumented

compiled =

Undocumented

compiled_parameters =

Undocumented

cursor =

Undocumented

dialect =

Undocumented

executemany =

Undocumented

execution_options =

Undocumented

extracted_parameters =

Undocumented

invoked_statement =

Undocumented

is_crud: bool =

Undocumented

is_text: bool =

Undocumented

isddl: bool =

Undocumented

isdelete =

Undocumented

isinsert =

Undocumented

isupdate =

Undocumented

parameters =

Undocumented

result_column_struct =

Undocumented

returned_default_rows =

Undocumented

root_connection =

Undocumented

statement =

Undocumented

unicode_statement =

Undocumented

@property
connection =

Undocumented

Undocumented

@util.memoized_property
identifier_preparer =

Undocumented

@util.memoized_property
inserted_primary_key_rows =

Undocumented

@util.memoized_property
no_parameters =

Undocumented

@util.memoized_property
postfetch_cols =

Undocumented

@util.memoized_property
prefetch_cols =

Undocumented

@util.memoized_property
returning_cols =

Undocumented

@util.memoized_property
should_autocommit =

Undocumented