class documentation

class Executable(roles.StatementRole, Generative):

Known subclasses: sqlalchemy.orm.query.Query, sqlalchemy.sql.ddl.DDLElement, sqlalchemy.sql.dml.UpdateBase, sqlalchemy.sql.elements.TextClause, sqlalchemy.sql.functions.FunctionElement, sqlalchemy.sql.schema.DefaultGenerator, sqlalchemy.sql.selectable.SelectBase, sqlalchemy.orm.query.FromStatement, sqlalchemy.sql.elements._IdentifiedClause

View In Hierarchy

Mark a _expression.ClauseElement as supporting execution.

.Executable is a superclass for all "statement" types of objects, including select, delete, update, insert, text.

Method ​_add​_context​_option Add a context option to this statement.
Method ​_set​_compile​_options Assign the compile options to a new value.
Method ​_update​_compile​_options update the _compile_options with new keys.
Method execute Compile and execute this .Executable.
Method execution​_options Set non-SQL options for the statement which take effect during execution.
Method get​_execution​_options Get the non-SQL options which will take effect during execution.
Method options Apply options to this statement.
Method scalar Compile and execute this .Executable, returning the result's scalar representation.
Class Variable ​_bind Undocumented
Class Variable ​_executable​_traverse​_internals Undocumented
Class Variable ​_with​_context​_options Undocumented
Class Variable ​_with​_options Undocumented
Class Variable is​_delete Undocumented
Class Variable is​_dml Undocumented
Class Variable is​_insert Undocumented
Class Variable is​_select Undocumented
Class Variable is​_text Undocumented
Class Variable is​_update Undocumented
Class Variable supports​_execution Undocumented
Instance Variable ​_compile​_options Undocumented
Instance Variable ​_execution​_options Undocumented
Property ​_effective​_plugin​_target Undocumented
Property bind Returns the _engine.Engine or _engine.Connection to which this .Executable is bound, or None if none found.

Inherited from StatementRole:

Class Variable ​_propagate​_attrs Undocumented
Class Variable ​_role​_name Undocumented

Inherited from SQLRole (via StatementRole):

Class Variable allows​_lambda Undocumented
Class Variable uses​_inspection Undocumented

Inherited from Generative:

Method ​_generate Undocumented
@_generative
def _add_context_option(self, callable_, cache_args):

Add a context option to this statement.

These are callable functions that will be given the CompileState object upon compilation.

A second argument cache_args is required, which will be combined with the __code__ identity of the function itself in order to produce a cache key.

@_generative
def _set_compile_options(self, compile_options):
Assign the compile options to a new value.
Parameters
compile​_optionsappropriate CacheableOptions structure
@_generative
def _update_compile_options(self, options):
update the _compile_options with new keys.
@util.deprecated_20(':meth:`.Executable.execute`', alternative='All statement execution in SQLAlchemy 2.0 is performed by the :meth:`_engine.Connection.execute` method of :class:`_engine.Connection`, or in the ORM by the :meth:`.Session.execute` method of :class:`.Session`.')
def execute(self, *multiparams, **params):
@_generative
def execution_options(self, **kw):

Set non-SQL options for the statement which take effect during execution.

Execution options can be set on a per-statement or per _engine.Connection basis. Additionally, the _engine.Engine and ORM ~.orm.query.Query objects provide access to execution options which they in turn configure upon connections.

The execution_options method is generative. A new instance of this statement is returned that contains the options:

statement = select(table.c.x, table.c.y)
statement = statement.execution_options(autocommit=True)

Note that only a subset of possible execution options can be applied to a statement - these include "autocommit" and "stream_results", but not "isolation_level" or "compiled_cache". See _engine.Connection.execution_options for a full list of possible options.

See Also

_engine.Connection.execution_options

_query.Query.execution_options

.Executable.get_execution_options

def get_execution_options(self):

Get the non-SQL options which will take effect during execution.

New in version 1.3.

See Also

.Executable.execution_options

@_generative
def options(self, *options):

Apply options to this statement.

In the general sense, options are any kind of Python object that can be interpreted by the SQL compiler for the statement. These options can be consumed by specific dialects or specific kinds of compilers.

The most commonly known kind of option are the ORM level options that apply "eager load" and other loading behaviors to an ORM query. However, options can theoretically be used for many other purposes.

For background on specific kinds of options for specific kinds of statements, refer to the documentation for those option objects.

Changed in version 1.4: - added .Generative.options to Core statement objects towards the goal of allowing unified Core / ORM querying capabilities.

See Also

:ref:`deferred_options` - refers to options specific to the usage of ORM queries

:ref:`relationship_loader_options` - refers to options specific to the usage of ORM queries

@util.deprecated_20(':meth:`.Executable.scalar`', alternative='Scalar execution in SQLAlchemy 2.0 is performed by the :meth:`_engine.Connection.scalar` method of :class:`_engine.Connection`, or in the ORM by the :meth:`.Session.scalar` method of :class:`.Session`.')
def scalar(self, *multiparams, **params):
Compile and execute this .Executable, returning the result's scalar representation.
_executable_traverse_internals =

Undocumented

_with_context_options: tuple =

Undocumented

_with_options: tuple =

Undocumented

is_delete: bool =

Undocumented

is_dml: bool =

Undocumented

is_insert: bool =

Undocumented

is_select: bool =

Undocumented

is_text: bool =

Undocumented

is_update: bool =

Undocumented

supports_execution: bool =

Undocumented

_compile_options =

Undocumented

@property
_effective_plugin_target =

Undocumented

@property
@util.deprecated_20(':attr:`.Executable.bind`', alternative='Bound metadata is being removed as of SQLAlchemy 2.0.', enable_warnings=False)
bind =

Returns the _engine.Engine or _engine.Connection to which this .Executable is bound, or None if none found.

This is a traversal which checks locally, then checks among the "from" clauses of associated objects until a bound engine or connection is found.