r"""Specify a fixed VALUES clause for an INSERT statement, or the SET clause for an UPDATE. Note that the :class:`_expression.Insert` and :class:`_expression.Update` constructs support per-execution time formatting of the VALUES and/or SET clauses, ba
(
self,
*args: Union[
_DMLColumnKeyMapping[Any],
Sequence[Any],
],
**kwargs: Any,
)
| 1050 | defaults={"_maintain_values_ordering": False}, |
| 1051 | ) |
| 1052 | def values( |
| 1053 | self, |
| 1054 | *args: Union[ |
| 1055 | _DMLColumnKeyMapping[Any], |
| 1056 | Sequence[Any], |
| 1057 | ], |
| 1058 | **kwargs: Any, |
| 1059 | ) -> Self: |
| 1060 | r"""Specify a fixed VALUES clause for an INSERT statement, or the SET |
| 1061 | clause for an UPDATE. |
| 1062 | |
| 1063 | Note that the :class:`_expression.Insert` and |
| 1064 | :class:`_expression.Update` |
| 1065 | constructs support |
| 1066 | per-execution time formatting of the VALUES and/or SET clauses, |
| 1067 | based on the arguments passed to :meth:`_engine.Connection.execute`. |
| 1068 | However, the :meth:`.ValuesBase.values` method can be used to "fix" a |
| 1069 | particular set of parameters into the statement. |
| 1070 | |
| 1071 | Multiple calls to :meth:`.ValuesBase.values` will produce a new |
| 1072 | construct, each one with the parameter list modified to include |
| 1073 | the new parameters sent. In the typical case of a single |
| 1074 | dictionary of parameters, the newly passed keys will replace |
| 1075 | the same keys in the previous construct. In the case of a list-based |
| 1076 | "multiple values" construct, each new list of values is extended |
| 1077 | onto the existing list of values. |
| 1078 | |
| 1079 | :param \**kwargs: key value pairs representing the string key |
| 1080 | of a :class:`_schema.Column` |
| 1081 | mapped to the value to be rendered into the |
| 1082 | VALUES or SET clause:: |
| 1083 | |
| 1084 | users.insert().values(name="some name") |
| 1085 | |
| 1086 | users.update().where(users.c.id == 5).values(name="some name") |
| 1087 | |
| 1088 | :param \*args: As an alternative to passing key/value parameters, |
| 1089 | a dictionary, tuple, or list of dictionaries or tuples can be passed |
| 1090 | as a single positional argument in order to form the VALUES or |
| 1091 | SET clause of the statement. The forms that are accepted vary |
| 1092 | based on whether this is an :class:`_expression.Insert` or an |
| 1093 | :class:`_expression.Update` construct. |
| 1094 | |
| 1095 | For either an :class:`_expression.Insert` or |
| 1096 | :class:`_expression.Update` |
| 1097 | construct, a single dictionary can be passed, which works the same as |
| 1098 | that of the kwargs form:: |
| 1099 | |
| 1100 | users.insert().values({"name": "some name"}) |
| 1101 | |
| 1102 | users.update().values({"name": "some new name"}) |
| 1103 | |
| 1104 | Also for either form but more typically for the |
| 1105 | :class:`_expression.Insert` construct, a tuple that contains an |
| 1106 | entry for every column in the table is also accepted:: |
| 1107 | |
| 1108 | users.insert().values((5, "some name")) |
| 1109 |
no test coverage detected