update_item - Boto3 1.34.74 documentation

Publish date: 2024-05-02
  • Key (dict) –

    [REQUIRED]

    The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute.

    For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.

  • AttributeUpdates (dict) –

    This is a legacy parameter. Use UpdateExpression instead. For more information, see AttributeUpdates in the Amazon DynamoDB Developer Guide.

  • Expected (dict) –

    This is a legacy parameter. Use ConditionExpression instead. For more information, see Expected in the Amazon DynamoDB Developer Guide.

  • ConditionalOperator (string) – This is a legacy parameter. Use ConditionExpression instead. For more information, see ConditionalOperator in the Amazon DynamoDB Developer Guide.

  • ReturnValues (string) –

    Use ReturnValues if you want to get the item attributes as they appear before or after they are successfully updated. For UpdateItem, the valid values are:

    There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.

    The values returned are strongly consistent.

  • ReturnConsumedCapacity (string) –

    Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:

  • ReturnItemCollectionMetrics (string) – Determines whether item collection metrics are returned. If set to SIZE, the response includes statistics about item collections, if any, that were modified during the operation are returned in the response. If set to NONE (the default), no statistics are returned.

  • UpdateExpression (string) –

    An expression that defines one or more attributes to be updated, the action to be performed on them, and new values for them.

    The following action values are available for UpdateExpression.

    These function names are case-sensitive.

    Warning

    The ADD action only supports Number and set data types. In addition, ADD can only be used on top-level attributes, not nested attributes.

    Warning

    The DELETE action only supports set data types. In addition, DELETE can only be used on top-level attributes, not nested attributes.

    You can have many actions in a single expression, such as the following: SET a=:value1, b=:value2 DELETE :value3, :value4, :value5

    For more information on update expressions, see Modifying Items and Attributes in the Amazon DynamoDB Developer Guide.

  • ConditionExpression (condition from boto3.dynamodb.conditions.Attr method) – The condition(s) an attribute(s) must meet. Valid conditions are listed in the DynamoDB Reference Guide.

  • ExpressionAttributeNames (dict) –

    One or more substitution tokens for attribute names in an expression. The following are some use cases for using ExpressionAttributeNames:

    Use the # character in an expression to dereference an attribute name. For example, consider the following attribute name:

    The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For the complete list of reserved words, see Reserved Words in the Amazon DynamoDB Developer Guide.) To work around this, you could specify the following for ExpressionAttributeNames:

    You could then use this substitution in an expression, as in this example:

    Note

    Tokens that begin with the : character are expression attribute values, which are placeholders for the actual value at runtime.

    For more information about expression attribute names, see Specifying Item Attributes in the Amazon DynamoDB Developer Guide.

  • ExpressionAttributeValues (dict) –

    One or more values that can be substituted in an expression.

    Use the : (colon) character in an expression to dereference an attribute value. For example, suppose that you wanted to check whether the value of the ProductStatus attribute was one of the following:

    Available | Backordered | Discontinued

    You would first need to specify ExpressionAttributeValues as follows:

    { ":avail":{"S":"Available"}, ":back":{"S":"Backordered"}, ":disc":{"S":"Discontinued"} }

    You could then use these values in an expression, such as this:

    ProductStatus IN (:avail, :back, :disc)

    For more information on expression attribute values, see Condition Expressions in the Amazon DynamoDB Developer Guide.

  • ReturnValuesOnConditionCheckFailure (string) –

    An optional parameter that returns the item attributes for an UpdateItem operation that failed a condition check.

    There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.

  • ncG1vNJzZmian6m8dHrAppizp56WxLR6wqikaK5hZLGwr9SmnKeskam2sLqOmqeiZ5yWwaa%2F02ipnp6Vp7Kvr8Roqp6qpp6wpr%2BOnbCnmZ2ksaN705qZpZ1fqr2lrdOelqKslaJ7qcDMpQ%3D%3D