class documentation

Undocumented

Method create_cursor Return a new cursor generated from this ExecutionContext's connection.
Method create_default_cursor Undocumented
Method create_server_side_cursor Undocumented
Method get_current_parameters Return a dictionary of parameters applied to the current row.
Method get_insert_default Undocumented
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 get_update_default Undocumented
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 supports_sane_multi_rowcount Undocumented
Method supports_sane_rowcount Undocumented
Instance Variable cache_hit Undocumented
Instance Variable compiled if passed to constructor, sqlalchemy.engine.base.Compiled object being executed
Instance Variable compiled_parameters Undocumented
Instance Variable current_parameters A dictionary of parameters applied to the current row.
Instance Variable cursor DB-API cursor procured from the connection
Instance Variable dialect dialect which created this ExecutionContext.
Instance Variable execute_style the style of DBAPI cursor method that will be used to execute a statement.
Instance Variable execution_options Undocumented
Instance Variable extracted_parameters Undocumented
Instance Variable invoked_statement The Executable statement object that was given in the first place.
Instance Variable is_crud Undocumented
Instance Variable is_text Undocumented
Instance Variable isddl Undocumented
Instance Variable isdelete Undocumented
Instance Variable isinsert True if the statement is an INSERT.
Instance Variable isupdate True if the statement is an UPDATE.
Instance Variable parameters bind parameters passed to the execute() or exec_driver_sql() methods.
Instance Variable result_column_struct Undocumented
Instance Variable returned_default_rows Undocumented
Instance Variable root_connection Connection object which is the source of this ExecutionContext.
Instance Variable 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.
Instance Variable unicode_statement Undocumented
Property 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.
Property engine engine which the Connection is associated with
Property executemany True if the context has a list of more than one parameter set.
Property identifier_preparer Undocumented
Property inserted_primary_key_rows Undocumented
Property no_parameters True if the execution style does not use parameters
Property 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.
Property prefetch_cols a list of Column objects for which a client-side default was fired off. Applies to inserts and updates.
Property rowcount Undocumented
Class Method _init_compiled Initialize execution context for a Compiled construct.
Class Method _init_ddl Initialize execution context for an ExecutableDDLElement 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 _prepare_set_input_sizes Given a cursor and ClauseParameters, prepare arguments in order to call the appropriate style of ``setinputsizes()`` on the cursor, using DB-API types from the bind parameter's ``TypeEngine`` objects.
Method _process_executemany_defaults Undocumented
Method _process_executesingle_defaults Undocumented
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
Class Variable _empty_dict_params Undocumented
Class Variable _has_rowcount Undocumented
Class Variable _insertmanyvalues_rows Undocumented
Class Variable _translate_colname Undocumented
Instance Variable _dbapi_connection Undocumented
Instance Variable _expanded_parameters used by set_input_sizes().
Instance Variable _is_explicit_returning Undocumented
Instance Variable _is_implicit_returning Undocumented
Instance Variable _is_server_side Undocumented
Instance Variable _is_supplemental_returning Undocumented
Instance Variable _soft_closed Undocumented

Inherited from ExecutionContext:

Method fire_sequence given a :class:`.Sequence`, invoke it and return the next int value
Method get_rowcount Return the DBAPI ``cursor.rowcount`` value, or in some cases an interpreted value.
def create_cursor(self): (source)

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): (source)

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 :class:`_schema.Column`, which is usually synonymous with the name. :param isolate_multiinsert_groups=True: indicates that multi-valued INSERT constructs created using :meth:`_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. .. versionadded:: 1.2 added :meth:`.DefaultExecutionContext.get_current_parameters` which provides more functionality over the existing :attr:`.DefaultExecutionContext.current_parameters` attribute. .. seealso:: :attr:`.DefaultExecutionContext.current_parameters` :ref:`context_default_functions`

def get_lastrowid(self): (source)

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 :meth:`.ExecutionContext.post_exec`.

def get_out_parameter_values(self, names): (source)

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 :class:`.SQLCompiler` object which has the :attr:`.SQLCompiler.has_out_parameters` flag set. This flag in turn will be set to True if the statement itself has :class:`.BindParameter` objects that have the ``.isoutparam`` flag set which are consumed by the :meth:`.SQLCompiler.visit_bindparam` method. If the dialect compiler produces :class:`.BindParameter` objects with ``.isoutparam`` set which are not handled by :meth:`.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. .. versionadded:: 1.4 - added :meth:`.ExecutionContext.get_out_parameter_values`, which is invoked automatically by the :class:`.DefaultExecutionContext` when there are :class:`.BindParameter` objects with the ``.isoutparam`` flag set. This replaces the practice of setting out parameters within the now-removed ``get_result_proxy()`` method.

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

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 get_update_default(self, column): (source)

Undocumented

def handle_dbapi_exception(self, e): (source)
def lastrow_has_defaults(self): (source)

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

def post_exec(self): (source)

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_exec(self): (source)

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 supports_sane_multi_rowcount(self): (source)

Undocumented

def supports_sane_rowcount(self): (source)

Undocumented

cache_hit = (source)

Undocumented

compiled = (source)

if passed to constructor, sqlalchemy.engine.base.Compiled object being executed

compiled_parameters = (source)

Undocumented

current_parameters = (source)

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 :class:`_schema.Column`, which is usually synonymous with the name. Note that the :attr:`.DefaultExecutionContext.current_parameters` attribute does not accommodate for the "multi-values" feature of the :meth:`_expression.Insert.values` method. The :meth:`.DefaultExecutionContext.get_current_parameters` method should be preferred. .. seealso:: :meth:`.DefaultExecutionContext.get_current_parameters` :ref:`context_default_functions`

DB-API cursor procured from the connection

execute_style = (source)

the style of DBAPI cursor method that will be used to execute a statement. .. versionadded:: 2.0

execution_options = (source)

Undocumented

extracted_parameters = (source)

Undocumented

invoked_statement = (source)

The Executable statement object that was given in the first place. This should be structurally equivalent to compiled.statement, but not necessarily the same object as in a caching scenario the compiled form will have been extracted from the cache.

Undocumented

Undocumented

Undocumented

isdelete = (source)

Undocumented

isinsert = (source)

True if the statement is an INSERT.

isupdate = (source)

True if the statement is an UPDATE.

parameters = (source)

bind parameters passed to the execute() or exec_driver_sql() methods. These are always stored as a list of parameter entries. A single-element list corresponds to a ``cursor.execute()`` call and a multiple-element list corresponds to ``cursor.executemany()``, except in the case of :attr:`.ExecuteStyle.INSERTMANYVALUES` which will use ``cursor.execute()`` one or more times.

result_column_struct = (source)

Undocumented

returned_default_rows = (source)

Undocumented

root_connection = (source)

Connection object which is the source of this ExecutionContext.

statement = (source)

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.

unicode_statement = (source)

Undocumented

@util.memoized_property
connection = (source)

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.

@util.memoized_property
engine = (source)

engine which the Connection is associated with

@property
executemany = (source)

True if the context has a list of more than one parameter set. Historically this attribute links to whether ``cursor.execute()`` or ``cursor.executemany()`` will be used. It also can now mean that "insertmanyvalues" may be used which indicates one or more ``cursor.execute()`` calls.

@util.memoized_property
identifier_preparer = (source)

Undocumented

@util.memoized_property
inserted_primary_key_rows = (source)

Undocumented

@util.memoized_property
no_parameters = (source)

True if the execution style does not use parameters

@util.memoized_property
postfetch_cols: Optional[Sequence[Column[Any]]] = (source)

a list of Column objects for which a server-side default or inline SQL expression value was fired off. Applies to inserts and updates.

@util.memoized_property
prefetch_cols: Optional[Sequence[Column[Any]]] = (source)

a list of Column objects for which a client-side default was fired off. Applies to inserts and updates.

@classmethod
def _init_compiled(cls, dialect: Dialect, connection: Connection, dbapi_connection: PoolProxiedConnection, execution_options: _ExecuteOptions, compiled: SQLCompiler, parameters: _CoreMultiExecuteParams, invoked_statement: Executable, extracted_parameters: Optional[Sequence[BindParameter[Any]]], cache_hit: CacheStats = CacheStats.CACHING_DISABLED) -> ExecutionContext: (source)

Initialize execution context for a Compiled construct.

@classmethod
def _init_ddl(cls, dialect: Dialect, connection: Connection, dbapi_connection: PoolProxiedConnection, execution_options: _ExecuteOptions, compiled_ddl: DDLCompiler) -> ExecutionContext: (source)

Initialize execution context for an ExecutableDDLElement construct.

@classmethod
def _init_default(cls, dialect: Dialect, connection: Connection, dbapi_connection: PoolProxiedConnection, execution_options: _ExecuteOptions) -> ExecutionContext: (source)

Initialize execution context for a ColumnDefault construct.

@classmethod
def _init_statement(cls, dialect: Dialect, connection: Connection, dbapi_connection: PoolProxiedConnection, execution_options: _ExecuteOptions, statement: str, parameters: _DBAPIMultiExecuteParams) -> ExecutionContext: (source)

Initialize execution context for a string SQL statement.

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

Undocumented

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

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 _prepare_set_input_sizes(self) -> Optional[List[Tuple[str, Any, TypeEngine[Any]]]]: (source)

Given a cursor and ClauseParameters, prepare arguments in order to 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 set the :attr:`.Dialect.bind_typing` attribute to :attr:`.BindTyping.SETINPUTSIZES`. cx_Oracle is the only DBAPI that requires setinputsizes(), pyodbc offers it as an option. Prior to SQLAlchemy 2.0, the setinputsizes() approach was also used for pg8000 and asyncpg, which has been changed to inline rendering of casts.

def _process_executemany_defaults(self): (source)

Undocumented

def _process_executesingle_defaults(self): (source)

Undocumented

def _setup_dml_or_text_result(self): (source)

Undocumented

def _setup_ins_pk_from_empty(self): (source)

Undocumented

def _setup_ins_pk_from_implicit_returning(self, result, rows): (source)

Undocumented

def _setup_ins_pk_from_lastrowid(self): (source)

Undocumented

def _setup_out_parameters(self, result): (source)

Undocumented

def _use_server_side_cursor(self): (source)

Undocumented

_empty_dict_params = (source)

Undocumented

_has_rowcount: bool = (source)

Undocumented

_insertmanyvalues_rows: Optional[List[Tuple[Any, ...]]] = (source)

Undocumented

_dbapi_connection = (source)

Undocumented

_expanded_parameters = (source)

used by set_input_sizes(). This collection comes from ``ExpandedState.parameter_expansion``.

_is_explicit_returning = (source)

Undocumented

_is_implicit_returning = (source)

Undocumented

_is_server_side: bool = (source)

Undocumented

_is_supplemental_returning: bool = (source)

Undocumented

_soft_closed = (source)

Undocumented