class UpdateBase(roles.DMLRole, HasCTE, HasCompileState, DialectKWArgs, HasPrefixes, Generative, ExecutableReturnsRows, ClauseElement): (source)
Known subclasses: sqlalchemy.sql.dml.Delete
, sqlalchemy.sql.dml.ValuesBase
Form the base for ``INSERT``, ``UPDATE``, and ``DELETE`` statements.
Method | corresponding |
Undocumented |
Method | params |
Set the parameters for the statement. |
Method | return |
Make use of a :term:`RETURNING` clause for the purpose of fetching server-side expressions and defaults, for supporting backends only. |
Method | returning |
Add a :term:`RETURNING` or equivalent clause to this statement. |
Method | with |
Add dialect options to this INSERT/UPDATE/DELETE object. |
Method | with |
Add a table hint for a single table to this INSERT/UPDATE/DELETE statement. |
Class Variable | __visit |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | named |
Undocumented |
Class Variable | table |
Undocumented |
Property | entity |
Return a :term:`plugin-enabled` description of the table and/or entity which this DML construct is operating against. |
Property | exported |
Return the RETURNING columns as a column collection for this statement. |
Property | returning |
Return a :term:`plugin-enabled` description of the columns which this DML construct is RETURNING against, in other words the expressions established as part of :meth:`.UpdateBase.returning`. |
Method | _generate |
Populate columns into an :class:`.AliasedReturnsRows` object. |
Class Variable | _returning |
Undocumented |
Instance Variable | _hints |
Undocumented |
Instance Variable | _return |
Undocumented |
Instance Variable | _return |
Undocumented |
Instance Variable | _supplemental |
Undocumented |
Property | _all |
A sequence of column expression objects that represents the "selected" columns of this :class:`_expression.ReturnsRows`. |
Inherited from DMLRole
:
Class Variable | __slots__ |
Undocumented |
Inherited from HasCTE
(via DMLRole
):
Method | add |
Add one or more :class:`_sql.CTE` constructs to this statement. |
Method | cte |
Return a new :class:`_expression.CTE`, or Common Table Expression instance. |
Class Variable | _has |
Undocumented |
Class Variable | _independent |
Undocumented |
Class Variable | _independent |
Undocumented |
Inherited from SelectsRows
(via DMLRole
, HasCTE
, HasCTERole
):
Method | _generate |
Generate column names as rendered in a SELECT statement by the compiler. |
Inherited from HasCompileState
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
):
Class Variable | _compile |
Undocumented |
Inherited from DialectKWArgs
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
):
Class Method | argument |
Add a new kind of dialect-specific keyword argument for this class. |
Property | dialect |
A collection of keyword arguments specified as dialect-specific options to this construct. |
Property | dialect |
A collection of keyword arguments specified as dialect-specific options to this construct. |
Property | kwargs |
A synonym for :attr:`.DialectKWArgs.dialect_kwargs`. |
Method | _kw |
Undocumented |
Method | _validate |
Undocumented |
Class Variable | _dialect |
Undocumented |
Class Variable | _kw |
Undocumented |
Inherited from HasPrefixes
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
):
Method | prefix |
Add one or more expressions following the statement keyword, i.e. SELECT, INSERT, UPDATE, or DELETE. Generative. |
Class Variable | _has |
Undocumented |
Instance Variable | _prefixes |
Undocumented |
Inherited from Generative
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
):
Method | _generate |
Undocumented |
Inherited from Executable
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
):
Method | execution |
Set non-SQL options for the statement which take effect during execution. |
Method | get |
Get the non-SQL options which will take effect during execution. |
Method | options |
Apply options to this statement. |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | supports |
Undocumented |
Method | _add |
Add a context option to this statement. |
Method | _compile |
Undocumented |
Method | _execute |
Undocumented |
Method | _execute |
Undocumented |
Method | _set |
Assign the compile options to a new value. |
Method | _update |
update the _compile_options with new keys. |
Class Variable | _executable |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _with |
Undocumented |
Class Variable | _with |
Undocumented |
Instance Variable | _compile |
Undocumented |
Instance Variable | _execution |
Undocumented |
Property | _effective |
Undocumented |
Inherited from StatementRole
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
):
Class Variable | _role |
Undocumented |
Property | _propagate |
Undocumented |
Inherited from ReturnsRows
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
):
Method | is |
Return ``True`` if this :class:`.ReturnsRows` is 'derived' from the given :class:`.FromClause`. |
Property | selectable |
Undocumented |
Method | _refresh |
reset internal collections for an incoming column being added. |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Inherited from SQLRole
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
):
Class Variable | allows |
Undocumented |
Class Variable | uses |
Undocumented |
Inherited from DQLDMLClauseElement
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
):
Method | compile |
Compile this SQL expression. |
Method | _compiler |
Return a compiler appropriate for this ClauseElement, given a Dialect. |
Inherited from ClauseElement
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
):
Method | __bool__ |
Undocumented |
Method | __getstate__ |
Undocumented |
Method | __invert__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | compare |
Compare this :class:`_expression.ClauseElement` to the given :class:`_expression.ClauseElement`. |
Method | get |
Return immediate child :class:`.visitors.HasTraverseInternals` elements of this :class:`.visitors.HasTraverseInternals`. |
Method | self |
Apply a 'grouping' to this :class:`_expression.ClauseElement`. |
Method | unique |
Return a copy with :func:`_expression.bindparam` elements replaced. |
Class Variable | is |
Undocumented |
Class Variable | is |
Undocumented |
Class Variable | negation |
Undocumented |
Property | description |
Undocumented |
Property | entity |
Undocumented |
Method | _clone |
Create a shallow copy of this ClauseElement. |
Method | _cloned |
Return the set consisting all cloned ancestors of this ClauseElement. |
Method | _negate |
Undocumented |
Method | _negate |
a hook to allow the right side of a binary expression to respond to a negation of the binary expression. |
Method | _replace |
Undocumented |
Method | _set |
Undocumented |
Method | _ungroup |
Return this :class:`_expression.ClauseElement` without any groupings. |
Method | _with |
in the context of binary expression, convert the type of this object to the one given. |
Class Variable | _cache |
Undocumented |
Class Variable | _gen |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Class Variable | _is |
Undocumented |
Property | _constructor |
return the 'constructor' for this ClauseElement. |
Property | _from |
Undocumented |
Property | _order |
Undocumented |
Inherited from SupportsWrappingAnnotations
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
):
Method | _annotate |
return a copy of this ClauseElement with annotations updated by the given dictionary. |
Method | _deannotate |
return a copy of this :class:`_expression.ClauseElement` with annotations removed. |
Method | _with |
return a copy of this ClauseElement with annotations replaced by the given dictionary. |
Inherited from SupportsAnnotations
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
):
Class Variable | proxy |
Undocumented |
Method | _gen |
Undocumented |
Property | _annotations |
Undocumented |
Inherited from MemoizedHasCacheKey
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
):
Method | _generate |
return a cache key. |
Inherited from HasCacheKey
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
):
Class Variable | inherit |
Indicate if this :class:`.HasCacheKey` instance should make use of the cache key generation scheme used by its immediate superclass. |
Class Method | _generate |
generate cache key dispatcher for a new class. |
Class Method | _generate |
Undocumented |
Method | _gen |
return an optional cache key. |
Class Variable | _generated |
Undocumented |
Class Variable | _hierarchy |
private attribute which may be set to False to prevent the inherit_cache warning from being emitted for a hierarchy of subclasses. |
Class Variable | _is |
Undocumented |
Inherited from HasCopyInternals
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
):
Method | _copy |
Reassign internal elements to be clones of themselves. |
Inherited from HasTraverseInternals
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, HasCopyInternals
, ExternallyTraversible
):
Class Variable | _traverse |
Undocumented |
Inherited from CompilerElement
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
):
Method | __str__ |
Undocumented |
Class Variable | stringify |
Undocumented |
Inherited from Visitable
(via DMLRole
, HasCTE
, HasCTERole
, SelectsRows
, HasCompileState
, DialectKWArgs
, HasPrefixes
, Generative
, ExecutableReturnsRows
, Executable
, StatementRole
, ReturnsRows
, ReturnsRowsRole
, SQLRole
, DQLDMLClauseElement
, ClauseElement
, SupportsWrappingAnnotations
, SupportsAnnotations
, MemoizedHasCacheKey
, HasCacheKey
, HasCopyInternals
, ExternallyTraversible
, HasTraverseInternals
, CompilerElement
):
Method | __class |
Undocumented |
Method | __init |
Undocumented |
Class Method | _generate |
Undocumented |
Method | _compiler |
Undocumented |
Class Variable | _original |
Undocumented |
KeyedColumnElement[ Any]
, require_embedded: bool
= False) -> Optional[ ColumnElement[ Any]]
:
(source)
¶
Undocumented
Set the parameters for the statement. This method raises ``NotImplementedError`` on the base class, and is overridden by :class:`.ValuesBase` to provide the SET/VALUES clause of UPDATE and INSERT.
def return_defaults(self, *cols:
_DMLColumnArgument
, supplemental_cols: Optional[ Iterable[ _DMLColumnArgument]]
= None) -> Self
:
(source)
¶
Make use of a :term:`RETURNING` clause for the purpose of fetching server-side expressions and defaults, for supporting backends only. .. deepalchemy:: The :meth:`.UpdateBase.return_defaults` method is used by the ORM for its internal work in fetching newly generated primary key and server default values, in particular to provide the underyling implementation of the :paramref:`_orm.Mapper.eager_defaults` ORM feature as well as to allow RETURNING support with bulk ORM inserts. Its behavior is fairly idiosyncratic and is not really intended for general use. End users should stick with using :meth:`.UpdateBase.returning` in order to add RETURNING clauses to their INSERT, UPDATE and DELETE statements. Normally, a single row INSERT statement will automatically populate the :attr:`.CursorResult.inserted_primary_key` attribute when executed, which stores the primary key of the row that was just inserted in the form of a :class:`.Row` object with column names as named tuple keys (and the :attr:`.Row._mapping` view fully populated as well). The dialect in use chooses the strategy to use in order to populate this data; if it was generated using server-side defaults and / or SQL expressions, dialect-specific approaches such as ``cursor.lastrowid`` or ``RETURNING`` are typically used to acquire the new primary key value. However, when the statement is modified by calling :meth:`.UpdateBase.return_defaults` before executing the statement, additional behaviors take place **only** for backends that support RETURNING and for :class:`.Table` objects that maintain the :paramref:`.Table.implicit_returning` parameter at its default value of ``True``. In these cases, when the :class:`.CursorResult` is returned from the statement's execution, not only will :attr:`.CursorResult.inserted_primary_key` be populated as always, the :attr:`.CursorResult.returned_defaults` attribute will also be populated with a :class:`.Row` named-tuple representing the full range of server generated values from that single row, including values for any columns that specify :paramref:`_schema.Column.server_default` or which make use of :paramref:`_schema.Column.default` using a SQL expression. When invoking INSERT statements with multiple rows using :ref:`insertmanyvalues <engine_insertmanyvalues>`, the :meth:`.UpdateBase.return_defaults` modifier will have the effect of the :attr:`_engine.CursorResult.inserted_primary_key_rows` and :attr:`_engine.CursorResult.returned_defaults_rows` attributes being fully populated with lists of :class:`.Row` objects representing newly inserted primary key values as well as newly inserted server generated values for each row inserted. The :attr:`.CursorResult.inserted_primary_key` and :attr:`.CursorResult.returned_defaults` attributes will also continue to be populated with the first row of these two collections. If the backend does not support RETURNING or the :class:`.Table` in use has disabled :paramref:`.Table.implicit_returning`, then no RETURNING clause is added and no additional data is fetched, however the INSERT, UPDATE or DELETE statement proceeds normally. E.g.:: stmt = table.insert().values(data='newdata').return_defaults() result = connection.execute(stmt) server_created_at = result.returned_defaults['created_at'] When used against an UPDATE statement :meth:`.UpdateBase.return_defaults` instead looks for columns that include :paramref:`_schema.Column.onupdate` or :paramref:`_schema.Column.server_onupdate` parameters assigned, when constructing the columns that will be included in the RETURNING clause by default if explicit columns were not specified. When used against a DELETE statement, no columns are included in RETURNING by default, they instead must be specified explicitly as there are no columns that normally change values when a DELETE statement proceeds. .. versionadded:: 2.0 :meth:`.UpdateBase.return_defaults` is supported for DELETE statements also and has been moved from :class:`.ValuesBase` to :class:`.UpdateBase`. The :meth:`.UpdateBase.return_defaults` method is mutually exclusive against the :meth:`.UpdateBase.returning` method and errors will be raised during the SQL compilation process if both are used at the same time on one statement. The RETURNING clause of the INSERT, UPDATE or DELETE statement is therefore controlled by only one of these methods at a time. The :meth:`.UpdateBase.return_defaults` method differs from :meth:`.UpdateBase.returning` in these ways: 1. :meth:`.UpdateBase.return_defaults` method causes the :attr:`.CursorResult.returned_defaults` collection to be populated with the first row from the RETURNING result. This attribute is not populated when using :meth:`.UpdateBase.returning`. 2. :meth:`.UpdateBase.return_defaults` is compatible with existing logic used to fetch auto-generated primary key values that are then populated into the :attr:`.CursorResult.inserted_primary_key` attribute. By contrast, using :meth:`.UpdateBase.returning` will have the effect of the :attr:`.CursorResult.inserted_primary_key` attribute being left unpopulated. 3. :meth:`.UpdateBase.return_defaults` can be called against any backend. Backends that don't support RETURNING will skip the usage of the feature, rather than raising an exception. The return value of :attr:`_engine.CursorResult.returned_defaults` will be ``None`` for backends that don't support RETURNING or for which the target :class:`.Table` sets :paramref:`.Table.implicit_returning` to ``False``. 4. An INSERT statement invoked with executemany() is supported if the backend database driver supports the :ref:`insertmanyvalues <engine_insertmanyvalues>` feature which is now supported by most SQLAlchemy-included backends. When executemany is used, the :attr:`_engine.CursorResult.returned_defaults_rows` and :attr:`_engine.CursorResult.inserted_primary_key_rows` accessors will return the inserted defaults and primary keys. .. versionadded:: 1.4 Added :attr:`_engine.CursorResult.returned_defaults_rows` and :attr:`_engine.CursorResult.inserted_primary_key_rows` accessors. In version 2.0, the underlying implementation which fetches and populates the data for these attributes was generalized to be supported by most backends, whereas in 1.4 they were only supported by the ``psycopg2`` driver. :param cols: optional list of column key names or :class:`_schema.Column` that acts as a filter for those columns that will be fetched. :param supplemental_cols: optional list of RETURNING expressions, in the same form as one would pass to the :meth:`.UpdateBase.returning` method. When present, the additional columns will be included in the RETURNING clause, and the :class:`.CursorResult` object will be "rewound" when returned, so that methods like :meth:`.CursorResult.all` will return new rows mostly as though the statement used :meth:`.UpdateBase.returning` directly. However, unlike when using :meth:`.UpdateBase.returning` directly, the **order of the columns is undefined**, so can only be targeted using names or :attr:`.Row._mapping` keys; they cannot reliably be targeted positionally. .. versionadded:: 2.0 .. seealso:: :meth:`.UpdateBase.returning` :attr:`_engine.CursorResult.returned_defaults` :attr:`_engine.CursorResult.returned_defaults_rows` :attr:`_engine.CursorResult.inserted_primary_key` :attr:`_engine.CursorResult.inserted_primary_key_rows`
def returning(self, *cols:
_ColumnsClauseArgument[ Any]
, **__kw: Any
) -> UpdateBase
:
(source)
¶
Add a :term:`RETURNING` or equivalent clause to this statement. e.g.: .. sourcecode:: pycon+sql >>> stmt = ( ... table.update() ... .where(table.c.data == "value") ... .values(status="X") ... .returning(table.c.server_flag, table.c.updated_timestamp) ... ) >>> print(stmt) {printsql}UPDATE some_table SET status=:status WHERE some_table.data = :data_1 RETURNING some_table.server_flag, some_table.updated_timestamp The method may be invoked multiple times to add new entries to the list of expressions to be returned. .. versionadded:: 1.4.0b2 The method may be invoked multiple times to add new entries to the list of expressions to be returned. The given collection of column expressions should be derived from the table that is the target of the INSERT, UPDATE, or DELETE. While :class:`_schema.Column` objects are typical, the elements can also be expressions: .. sourcecode:: pycon+sql >>> stmt = table.insert().returning( ... (table.c.first_name + " " + table.c.last_name).label("fullname") ... ) >>> print(stmt) {printsql}INSERT INTO some_table (first_name, last_name) VALUES (:first_name, :last_name) RETURNING some_table.first_name || :first_name_1 || some_table.last_name AS fullname Upon compilation, a RETURNING clause, or database equivalent, will be rendered within the statement. For INSERT and UPDATE, the values are the newly inserted/updated values. For DELETE, the values are those of the rows which were deleted. Upon execution, the values of the columns to be returned are made available via the result set and can be iterated using :meth:`_engine.CursorResult.fetchone` and similar. For DBAPIs which do not natively support returning values (i.e. cx_oracle), SQLAlchemy will approximate this behavior at the result level so that a reasonable amount of behavioral neutrality is provided. Note that not all databases/DBAPIs support RETURNING. For those backends with no support, an exception is raised upon compilation and/or execution. For those who do support it, the functionality across backends varies greatly, including restrictions on executemany() and other statements which return multiple rows. Please read the documentation notes for the database in use in order to determine the availability of RETURNING. .. seealso:: :meth:`.UpdateBase.return_defaults` - an alternative method tailored towards efficient fetching of server-side defaults and triggers for single-row INSERTs or UPDATEs. :ref:`tutorial_insert_returning` - in the :ref:`unified_tutorial`
Add dialect options to this INSERT/UPDATE/DELETE object. e.g.:: upd = table.update().dialect_options(mysql_limit=10) .. versionadded: 1.4 - this method supersedes the dialect options associated with the constructor.
def with_hint(self, text:
str
, selectable: Optional[ _DMLTableArgument]
= None, dialect_name: str
= '*') -> Self
:
(source)
¶
Add a table hint for a single table to this INSERT/UPDATE/DELETE statement. .. note:: :meth:`.UpdateBase.with_hint` currently applies only to Microsoft SQL Server. For MySQL INSERT/UPDATE/DELETE hints, use :meth:`.UpdateBase.prefix_with`. The text of the hint is rendered in the appropriate location for the database backend in use, relative to the :class:`_schema.Table` that is the subject of this statement, or optionally to that of the given :class:`_schema.Table` passed as the ``selectable`` argument. The ``dialect_name`` option will limit the rendering of a particular hint to a particular backend. Such as, to add a hint that only takes effect for SQL Server:: mytable.insert().with_hint("WITH (PAGLOCK)", dialect_name="mssql") :param text: Text of the hint. :param selectable: optional :class:`_schema.Table` that specifies an element of the FROM clause within an UPDATE or DELETE to be the subject of the hint - applies only to certain backends. :param dialect_name: defaults to ``*``, if specified as the name of a particular dialect, will apply these hints only when that dialect is in use.
Return a :term:`plugin-enabled` description of the table and/or entity which this DML construct is operating against. This attribute is generally useful when using the ORM, as an extended structure which includes information about mapped entities is returned. The section :ref:`queryguide_inspection` contains more background. For a Core statement, the structure returned by this accessor is derived from the :attr:`.UpdateBase.table` attribute, and refers to the :class:`.Table` being inserted, updated, or deleted:: >>> stmt = insert(user_table) >>> stmt.entity_description { "name": "user_table", "table": Table("user_table", ...) } .. versionadded:: 1.4.33 .. seealso:: :attr:`.UpdateBase.returning_column_descriptions` :attr:`.Select.column_descriptions` - entity information for a :func:`.select` construct :ref:`queryguide_inspection` - ORM background
exported_columns:
ReadOnlyColumnCollection[ Optional[ str], ColumnElement[ Any]]
=
(source)
¶
Return the RETURNING columns as a column collection for this statement. .. versionadded:: 1.4
Return a :term:`plugin-enabled` description of the columns which this DML construct is RETURNING against, in other words the expressions established as part of :meth:`.UpdateBase.returning`. This attribute is generally useful when using the ORM, as an extended structure which includes information about mapped entities is returned. The section :ref:`queryguide_inspection` contains more background. For a Core statement, the structure returned by this accessor is derived from the same objects that are returned by the :attr:`.UpdateBase.exported_columns` accessor:: >>> stmt = insert(user_table).returning(user_table.c.id, user_table.c.name) >>> stmt.entity_description [ { "name": "id", "type": Integer, "expr": Column("id", Integer(), table=<user>, ...) }, { "name": "name", "type": String(), "expr": Column("name", String(), table=<user>, ...) }, ] .. versionadded:: 1.4.33 .. seealso:: :attr:`.UpdateBase.entity_description` :attr:`.Select.column_descriptions` - entity information for a :func:`.select` construct :ref:`queryguide_inspection` - ORM background