1

I need to update a row in Dynomodb while doing so need to include a new column which is already not there.

resp = table.update_item(
            Key={
                'Pkey': 'key1',
                'Skey': 'skwy2'
            },
            UpdateExpression='ADD dateModified = :input2, SET IsActive = :input1',
            ExpressionAttributeValues={
                ':input1': False,
                ':input2' :  datetime.datetime.now(timezone.utc)
            },
            ReturnValues="UPDATED_NEW"
        )

now I need to update IsActive field to false and insert new dateModified value to that .

getting error as Invalid UpdateExpression: Syntax error; token: "=", near: "dateModified = :input2"

1 Answer 1

1

you can see in https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.ADD that for the ADD operation you don't use =

so the correct expression should be ADD dateModified :input2 SET IsActive = :input1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.