Geo*_*e B 1 boto amazon-web-services python-2.7 amazon-dynamodb
我有一个字符串字段“ title”。我正在尝试使用更新表达式更新它
persontable.update_item(Key={'person_id':person_id}, UpdateExpression="SET title = UPDATED")
Run Code Online (Sandbox Code Playgroud)
我得到
An error occurred (ValidationException) when calling the UpdateItem operation: The provided expression refers to an attribute that does not exist in the item
Run Code Online (Sandbox Code Playgroud)
我可以在AWS控制台中看到该人的属性“ title”。是什么赋予了?
不要将值直接插入表达式中。而是使用ExpressionAttributeValues-请参阅boto3指南
persontable.update_item(Key={'person_id':person_id},
UpdateExpression="SET title = :updated",
ExpressionAttributeValues={':updated': 'UPDATED'})
Run Code Online (Sandbox Code Playgroud)