【发布时间】:2021-12-23 18:34:34
【问题描述】:
在the documentation 之后,我正在尝试创建一个更新语句,如果 dynamodb 表中不存在一个属性,则该语句将更新或添加。
我正在尝试这个
response = table.update_item(
Key={'ReleaseNumber': '1.0.179'},
UpdateExpression='SET',
ConditionExpression='Attr(\'ReleaseNumber\').eq(\'1.0.179\')',
ExpressionAttributeNames={'attr1': 'val1'},
ExpressionAttributeValues={'val1': 'false'}
)
我得到的错误是:
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the UpdateItem operation: ExpressionAttributeNames contains invalid key: Syntax error; key: "attr1"
如果有人做过类似我想要实现的事情,请分享示例。
【问题讨论】:
-
我知道这是一个非常古老的问题,但我想知道....如果您的项目已经存在,“put_item”将覆盖它。如果我不能更改任何 index_key ,为什么要使用 update_item ?
-
@Claudiu 我想更新不是所有字段
标签: python amazon-dynamodb boto3 botocore