MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / values

Method values

lib/sqlalchemy/sql/dml.py:1033–1203  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 15

_set_typeMethod · 0.45
_mergeMethod · 0.45
_remove_tableMethod · 0.45
sorted_tablesMethod · 0.45
_join_conditionMethod · 0.45
_copy_internalsMethod · 0.45
_make_extra_fromsMethod · 0.45
visit_metadataMethod · 0.45
visit_metadataMethod · 0.45
_process_numericMethod · 0.45

Calls 4

castFunction · 0.85
get_plugin_classMethod · 0.45
itemsMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected