我有一个字符串字段,“标题”。我正在尝试使用更新表达式更新它
persontable.update_item(Key={'person_id':person_id}, UpdateExpression="SET title = UPDATED")
我得到
An error occurred (ValidationException) when calling the UpdateItem operation: The provided expression refers to an attribute that does not exist in the item
我可以在 AWS 控制台中看到该人的属性“title”。是什么赋予了?
最佳答案
不要将值直接插入表达式中。而是使用 ExpressionAttributeValues -- 见 boto3 guide
persontable.update_item(Key={'person_id':person_id},
UpdateExpression="SET title = :updated",
ExpressionAttributeValues={':updated': 'UPDATED'})
关于python-2.7 - Dynamodb 使用 python boto3 更新项目表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34689912/