class documentation

class MSExecutionContext(default.DefaultExecutionContext):

Known subclasses: sqlalchemy.dialects.mssql.pyodbc.MSExecutionContext_pyodbc

View In Hierarchy

Undocumented

Method ​_opt​_encode Undocumented
Method fire​_sequence Undocumented
Method get​_insert​_default Undocumented
Method get​_lastrowid return self.cursor.lastrowid, or equivalent, after an INSERT.
Method get​_result​_cursor​_strategy Return a result cursor strategy for a given result object.
Method handle​_dbapi​_exception Receive a DBAPI exception which occurred upon execute, result fetch, etc.
Method post​_exec Disable IDENTITY_INSERT if enabled.
Method pre​_exec Activate IDENTITY_INSERT if needed.
Class Variable ​_result​_strategy Undocumented
Instance Variable ​_enable​_identity​_insert Undocumented
Instance Variable ​_lastrowid Undocumented
Instance Variable ​_rowcount Undocumented
Instance Variable ​_select​_lastrowid Undocumented
Property rowcount Undocumented

Inherited from DefaultExecutionContext:

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​_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 lastrow​_has​_defaults Return True if the last INSERT or UPDATE row contained inlined or database-side defaults.
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​_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 should​_autocommit Undocumented

Inherited from ExecutionContext (via DefaultExecutionContext):

Method get​_rowcount Return the DBAPI cursor.rowcount value, or in some cases an interpreted value.
def _opt_encode(self, statement):

Undocumented

def fire_sequence(self, seq, type_):

Undocumented

def get_insert_default(self, column):
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_result_cursor_strategy(self, result):

Return a result cursor strategy for a given result object.

This method is implemented by the .DefaultDialect and is only needed by implementing dialects in the case where some special steps regarding the cursor must be taken, such as manufacturing fake results from some other element of the cursor, or pre-buffering the cursor's results.

A simplified version of the default implementation is:

from sqlalchemy.engine.result import DefaultCursorFetchStrategy

class MyExecutionContext(DefaultExecutionContext):
    def get_result_cursor_strategy(self, result):
        return DefaultCursorFetchStrategy.create(result)

Above, the .DefaultCursorFetchStrategy will be applied to the result object. For results that are pre-buffered from a cursor that might be closed, an implementation might be:

from sqlalchemy.engine.result import (
    FullyBufferedCursorFetchStrategy
)

class MyExecutionContext(DefaultExecutionContext):
    _pre_buffered_result = None

    def pre_exec(self):
        if self.special_condition_prebuffer_cursor():
            self._pre_buffered_result = (
                self.cursor.description,
                self.cursor.fetchall()
            )

    def get_result_cursor_strategy(self, result):
        if self._pre_buffered_result:
            description, cursor_buffer = self._pre_buffered_result
            return (
                FullyBufferedCursorFetchStrategy.
                    create_from_buffer(
                        result, description, cursor_buffer
                )
            )
        else:
            return DefaultCursorFetchStrategy.create(result)

This method replaces the previous not-quite-documented get_result_proxy() method.

New in version 1.4: - result objects now interpret cursor results based on a pluggable "strategy" object, which is delivered by the .ExecutionContext via the .ExecutionContext.get_result_cursor_strategy method.

See Also

.ExecutionContext.get_out_parameter_values

def handle_dbapi_exception(self, e):
Receive a DBAPI exception which occurred upon execute, result fetch, etc.
def post_exec(self):
def pre_exec(self):
_result_strategy =

Undocumented

_enable_identity_insert =

Undocumented

_lastrowid =
_rowcount =

Undocumented

_select_lastrowid =

Undocumented

@property
rowcount =