Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamodb Update Item Expression with python boto3

I have a string field, "title". I am trying to update it with the update expression with

persontable.update_item(Key={'person_id':person_id}, UpdateExpression="SET title = UPDATED")

and I get

An error occurred (ValidationException) when calling the UpdateItem operation: The provided expression refers to an attribute that does not exist in the item

I can see the attribute "title" for that person in the AWS console. What gives?

like image 407
George B Avatar asked Jan 09 '16 05:01

George B


1 Answers

Don't plug the value into the expression directly. Rather use ExpressionAttributeValues -- see boto3 guide

persontable.update_item(Key={'person_id':person_id},
                        UpdateExpression="SET title = :updated",                   
                        ExpressionAttributeValues={':updated': 'UPDATED'})
like image 86
user254873 Avatar answered Nov 15 '22 06:11

user254873