class Insert(StandardInsert):
SQLite-specific implementation of INSERT.
Adds methods for SQLite-specific syntaxes such as ON CONFLICT.
The _sqlite.Insert
object is created using the
sqlalchemy.dialects.sqlite.insert
function.
See Also
Method | on_conflict_do_nothing |
Specifies a DO NOTHING action for ON CONFLICT clause. |
Method | on_conflict_do_update |
Specifies a DO UPDATE SET action for ON CONFLICT clause. |
Class Variable | _on_conflict_exclusive |
Undocumented |
Class Variable | inherit_cache |
Undocumented |
Class Variable | stringify_dialect |
Undocumented |
Instance Variable | _post_values_clause |
Undocumented |
Property | excluded |
Provide the excluded namespace for an ON CONFLICT statement |
Parameters | |
index_elements | A sequence consisting of string column names, _schema.Column
objects, or other column expression objects that will be used
to infer a target index or unique constraint. |
index_where | Additional WHERE criterion that can be used to infer a conditional target index. |
Parameters | |
index_elements | A sequence consisting of string column names, _schema.Column
objects, or other column expression objects that will be used
to infer a target index or unique constraint. |
index_where | Additional WHERE criterion that can be used to infer a conditional target index. |
set_ | A dictionary or other mapping object
where the keys are either names of columns in the target table,
or
New in version 1.4: The
:paramref:`_sqlite.Insert.on_conflict_do_update.set_`
parameter supports
_schema.Column objects from the target
_schema.Table as keys.Warning This dictionary does not take into account Python-specified default UPDATE values or generation functions, e.g. those specified using :paramref:`_schema.Column.onupdate`. These values will not be exercised for an ON CONFLICT style of UPDATE, unless they are manually specified in the :paramref:`.Insert.on_conflict_do_update.set_` dictionary. |
where | Optional argument. If present, can be a literal SQL string or an acceptable expression for a WHERE clause that restricts the rows affected by DO UPDATE SET. Rows not meeting the WHERE condition will not be updated (effectively a DO NOTHING for those rows). |
Provide the excluded namespace for an ON CONFLICT statement
SQLite's ON CONFLICT clause allows reference to the row that would be inserted, known as excluded. This attribute provides all columns in this row to be referenceable.
Tip
The _sqlite.Insert.excluded
attribute is an instance
of _expression.ColumnCollection
, which provides an
interface the same as that of the _schema.Table.c
collection described at :ref:`metadata_tables_and_columns`.
With this collection, ordinary names are accessible like attributes
(e.g. stmt.excluded.some_column), but special names and
dictionary method names should be accessed using indexed access,
such as stmt.excluded["column name"] or
stmt.excluded["values"]. See the docstring for
_expression.ColumnCollection
for further examples.