SQLite-specific implementation of INSERT. Adds methods for SQLite-specific syntaxes such as ON CONFLICT. The :class:`_sqlite.Insert` object is created using the :func:`sqlalchemy.dialects.sqlite.insert` function. .. versionadded:: 1.4 .. seealso:: :ref:`sqlite_on_con
| 60 | |
| 61 | |
| 62 | class Insert(StandardInsert): |
| 63 | """SQLite-specific implementation of INSERT. |
| 64 | |
| 65 | Adds methods for SQLite-specific syntaxes such as ON CONFLICT. |
| 66 | |
| 67 | The :class:`_sqlite.Insert` object is created using the |
| 68 | :func:`sqlalchemy.dialects.sqlite.insert` function. |
| 69 | |
| 70 | .. versionadded:: 1.4 |
| 71 | |
| 72 | .. seealso:: |
| 73 | |
| 74 | :ref:`sqlite_on_conflict_insert` |
| 75 | |
| 76 | """ |
| 77 | |
| 78 | stringify_dialect = "sqlite" |
| 79 | inherit_cache = True |
| 80 | |
| 81 | @util.memoized_property |
| 82 | def excluded( |
| 83 | self, |
| 84 | ) -> ReadOnlyColumnCollection[str, KeyedColumnElement[Any]]: |
| 85 | """Provide the ``excluded`` namespace for an ON CONFLICT statement |
| 86 | |
| 87 | SQLite's ON CONFLICT clause allows reference to the row that would |
| 88 | be inserted, known as ``excluded``. This attribute provides |
| 89 | all columns in this row to be referenceable. |
| 90 | |
| 91 | .. tip:: The :attr:`_sqlite.Insert.excluded` attribute is an instance |
| 92 | of :class:`_expression.ColumnCollection`, which provides an |
| 93 | interface the same as that of the :attr:`_schema.Table.c` |
| 94 | collection described at :ref:`metadata_tables_and_columns`. |
| 95 | With this collection, ordinary names are accessible like attributes |
| 96 | (e.g. ``stmt.excluded.some_column``), but special names and |
| 97 | dictionary method names should be accessed using indexed access, |
| 98 | such as ``stmt.excluded["column name"]`` or |
| 99 | ``stmt.excluded["values"]``. See the docstring for |
| 100 | :class:`_expression.ColumnCollection` for further examples. |
| 101 | |
| 102 | """ |
| 103 | return alias(self.table, name="excluded").columns |
| 104 | |
| 105 | _on_conflict_exclusive = _exclusive_against( |
| 106 | "_post_values_clause", |
| 107 | msgs={ |
| 108 | "_post_values_clause": "This Insert construct already has " |
| 109 | "an ON CONFLICT clause established" |
| 110 | }, |
| 111 | ) |
| 112 | |
| 113 | @_on_conflict_exclusive |
| 114 | def on_conflict_do_update( |
| 115 | self, |
| 116 | index_elements: _OnConflictIndexElementsT = None, |
| 117 | index_where: _OnConflictIndexWhereT = None, |
| 118 | set_: _OnConflictSetT = None, |
| 119 | where: _OnConflictWhereT = None, |
no test coverage detected