class DefaultExecutionContext(ExecutionContext): (source)
Known subclasses: sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.mysql.base.MySQLExecutionContext
, sqlalchemy.dialects.oracle.base.OracleExecutionContext
, sqlalchemy.dialects.postgresql.base.PGExecutionContext
, sqlalchemy.dialects.sqlite.base.SQLiteExecutionContext
Undocumented
Method | create |
Return a new cursor generated from this ExecutionContext's connection. |
Method | create |
Undocumented |
Method | create |
Undocumented |
Method | get |
Return a dictionary of parameters applied to the current row. |
Method | get |
Undocumented |
Method | get |
return self.cursor.lastrowid, or equivalent, after an INSERT. |
Method | get |
Return a sequence of OUT parameter values from a cursor. |
Method | get |
Return a 'result processor' for a given type as present in cursor.description. |
Method | get |
Undocumented |
Method | handle |
Receive a DBAPI exception which occurred upon execute, result fetch, etc. |
Method | lastrow |
Return True if the last INSERT or UPDATE row contained inlined or database-side defaults. |
Method | post |
Called after the execution of a compiled statement. |
Method | pre |
Called before an execution of a compiled statement. |
Method | supports |
Undocumented |
Method | supports |
Undocumented |
Instance Variable | cache |
Undocumented |
Instance Variable | compiled |
if passed to constructor, sqlalchemy.engine.base.Compiled object being executed |
Instance Variable | compiled |
Undocumented |
Instance Variable | current |
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 |
the style of DBAPI cursor method that will be used to execute a statement. |
Instance Variable | execution |
Undocumented |
Instance Variable | extracted |
Undocumented |
Instance Variable | invoked |
The Executable statement object that was given in the first place. |
Instance Variable | is |
Undocumented |
Instance Variable | is |
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 |
Undocumented |
Instance Variable | returned |
Undocumented |
Instance Variable | root |
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 |
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 |
Undocumented |
Property | inserted |
Undocumented |
Property | no |
True if the execution style does not use parameters |
Property | postfetch |
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 |
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 |
Initialize execution context for a Compiled construct. |
Class Method | _init |
Initialize execution context for an ExecutableDDLElement construct. |
Class Method | _init |
Initialize execution context for a ColumnDefault construct. |
Class Method | _init |
Initialize execution context for a string SQL statement. |
Method | _exec |
Undocumented |
Method | _exec |
Undocumented |
Method | _execute |
Execute a string statement on the current cursor, returning a scalar result. |
Method | _get |
Undocumented |
Method | _prepare |
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 |
Undocumented |
Method | _process |
Undocumented |
Method | _setup |
Undocumented |
Method | _setup |
Undocumented |
Method | _setup |
Undocumented |
Method | _setup |
Undocumented |
Method | _setup |
Undocumented |
Method | _setup |
Undocumented |
Method | _use |
Undocumented |
Class Variable | _empty |
Undocumented |
Class Variable | _has |
Undocumented |
Class Variable | _insertmanyvalues |
Undocumented |
Class Variable | _translate |
Undocumented |
Instance Variable | _dbapi |
Undocumented |
Instance Variable | _expanded |
used by set_input_sizes(). |
Instance Variable | _is |
Undocumented |
Instance Variable | _is |
Undocumented |
Instance Variable | _is |
Undocumented |
Instance Variable | _is |
Undocumented |
Instance Variable | _soft |
Undocumented |
Inherited from ExecutionContext
:
Method | fire |
given a :class:`.Sequence`, invoke it and return the next int value |
Method | get |
Return the DBAPI ``cursor.rowcount`` value, or in some cases an interpreted value. |
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.
sqlalchemy.dialects.mysql.base.MySQLExecutionContext
, sqlalchemy.dialects.postgresql.asyncpg.PGExecutionContext_asyncpg
, sqlalchemy.dialects.postgresql.pg8000.PGExecutionContext_pg8000
, sqlalchemy.dialects.sqlite.aiosqlite.SQLiteExecutionContext_aiosqlite
, sqlalchemy.dialects.postgresql._psycopg_common._PGExecutionContext_common_psycopg
Undocumented
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`
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.postgresql.base.PGExecutionContext
Undocumented
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.mysql.mariadbconnector.MySQLExecutionContext_mariadbconnector
, sqlalchemy.dialects.mysql.pyodbc.MySQLExecutionContext_pyodbc
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`.
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.
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.
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.postgresql.asyncpg.PGExecutionContext_asyncpg
Receive a DBAPI exception which occurred upon execute, result fetch, etc.
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.mysql.mariadbconnector.MySQLExecutionContext_mariadbconnector
, sqlalchemy.dialects.oracle.cx_oracle.OracleExecutionContext_cx_oracle
, sqlalchemy.dialects.postgresql.psycopg2.PGExecutionContext_psycopg2
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.
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.oracle.base.OracleExecutionContext
, sqlalchemy.dialects.postgresql.asyncpg.PGExecutionContext_asyncpg
, sqlalchemy.dialects.postgresql.pg8000.PGExecutionContext_pg8000
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.
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`
sqlalchemy.dialects.mssql.base.MSExecutionContext
dialect which created this ExecutionContext.
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.
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.
sqlalchemy.dialects.oracle.base.OracleExecutionContext
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.
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.
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.
a list of Column objects for which a server-side default or inline SQL expression value was fired off. Applies to inserts and updates.
a list of Column objects for which a client-side default was fired off. Applies to inserts and updates.
sqlalchemy.dialects.mssql.base.MSExecutionContext
, sqlalchemy.dialects.mysql.mysqldb.MySQLExecutionContext_mysqldb
Undocumented
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.
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.
def _init_default(cls, dialect:
Dialect
, connection: Connection
, dbapi_connection: PoolProxiedConnection
, execution_options: _ExecuteOptions
) -> ExecutionContext
:
(source)
¶
Initialize execution context for a ColumnDefault construct.
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.
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.
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.