MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / on_conflict_do_update

Method on_conflict_do_update

lib/sqlalchemy/dialects/sqlite/dml.py:114–162  ·  view source on GitHub ↗

r""" Specifies a DO UPDATE SET action for ON CONFLICT clause. :param index_elements: A sequence consisting of string column names, :class:`_schema.Column` objects, or other column expression objects that will be used to infer a target index or unique const

(
        self,
        index_elements: _OnConflictIndexElementsT = None,
        index_where: _OnConflictIndexWhereT = None,
        set_: _OnConflictSetT = None,
        where: _OnConflictWhereT = None,
    )

Source from the content-addressed store, hash-verified

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,
120 ) -> Self:
121 r"""
122 Specifies a DO UPDATE SET action for ON CONFLICT clause.
123
124 :param index_elements:
125 A sequence consisting of string column names, :class:`_schema.Column`
126 objects, or other column expression objects that will be used
127 to infer a target index or unique constraint.
128
129 :param index_where:
130 Additional WHERE criterion that can be used to infer a
131 conditional target index.
132
133 :param set\_:
134 A dictionary or other mapping object
135 where the keys are either names of columns in the target table,
136 or :class:`_schema.Column` objects or other ORM-mapped columns
137 matching that of the target table, and expressions or literals
138 as values, specifying the ``SET`` actions to take.
139
140 .. versionadded:: 1.4 The
141 :paramref:`_sqlite.Insert.on_conflict_do_update.set_`
142 parameter supports :class:`_schema.Column` objects from the target
143 :class:`_schema.Table` as keys.
144
145 .. warning:: This dictionary does **not** take into account
146 Python-specified default UPDATE values or generation functions,
147 e.g. those specified using :paramref:`_schema.Column.onupdate`.
148 These values will not be exercised for an ON CONFLICT style of
149 UPDATE, unless they are manually specified in the
150 :paramref:`.Insert.on_conflict_do_update.set_` dictionary.
151
152 :param where:
153 Optional argument. An expression object representing a ``WHERE``
154 clause that restricts the rows affected by ``DO UPDATE SET``. Rows not
155 meeting the ``WHERE`` condition will not be updated (effectively a
156 ``DO NOTHING`` for those rows).
157
158 """
159
160 return self.ext(
161 OnConflictDoUpdate(index_elements, index_where, set_, where)
162 )
163
164 @_on_conflict_exclusive
165 def on_conflict_do_nothing(

Callers 15

_upsertFunction · 0.45
test_insert_on_conflictFunction · 0.45
sqlite_stuff.pyFile · 0.45
stmt3Method · 0.45
stmt31Method · 0.45
stmt4Method · 0.45
stmt41Method · 0.45
stmt42Method · 0.45
test_set_excludedMethod · 0.45

Calls 2

OnConflictDoUpdateClass · 0.70
extMethod · 0.45

Tested by 15

test_insert_on_conflictFunction · 0.36
stmt3Method · 0.36
stmt31Method · 0.36
stmt4Method · 0.36
stmt41Method · 0.36
stmt42Method · 0.36
test_set_excludedMethod · 0.36