- Newest
- Most votes
- Most comments
For ExpressionAttributeNames
, map a placeholder to the actual attribute name, e.g., {'#lsq': 'LargestSeQNo'}
, and for ExpressionAttributeValues
, map a placeholder to the new value, e.g., {':val1': SeqNo}
.
ℹ️
ExpressionAttributeNames
andExpressionAttributeValues
are dictionaries not string.
ℹ️ Use the
#
character in an expression to dereference an attribute name.
ℹ️ Use the
: (colon)
character in an expression to dereference an attribute value.
🔗 For more information about
ExpressionAttributeNames
andExpressionAttributeValues
check update_item in Boto3.
Good points - documented!
First, the error message in your comment "'str' object has no attribute 'update'"
tells me that you're calling a method update
but I don't see that in your code anywhere. I can see table.update_item
but that's not the same thing. Have you deployed your Lambda before you are testing it?
Second, to the error message in the original question: ExpressionAttributeValues contains invalid key
you might try this instead:
responseSeQ = table.update_item( //line 79
Key={ 'ID': '1', 'Highest' : '1' },
ExpressionAttributeNames={'#LargestSequenceNumber':'LargestSeQNo'},
UpdateExpression='set #LargestSequenceNumber = :SequenceNumber',
ExpressionAttributeValues={ ':SequenceNumber':SeqNo }
)
Note that you can also (sometimes) go simpler depending on whether your attributes are DynamoDB keywords or not:
responseSeQ = table.update_item( //line 79
Key={ 'ID': '1', 'Highest' : '1' },
AttributeUpdate={'LargestSeQNo':{''Value':SeqNo'}}
)
The 2nd simplier approach complains about a syntax error in the AttributeUpdats={'LargestSeQNo':{''Value':SeqNo'}} line.
BUT, Good news, the 1st approach worked! Thank you for your help.
Thanks - fixed. I was transcribing from another computer rather than copy/pasting.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago
I've gotten a little further, but no cigar yet....Here's the current code
Error "errorMessage": "'str' object has no attribute 'update'", "errorType": "AttributeError", "requestId": "f646ba1a-8665-4332-93cd-0f8562988a0c", "stackTrace": [ " File "/var/task/lambda_function.py", line 79, in lambda_handler\n responseSeQ = table.update_item(\n",