UpdateAtomicItem.py 447 B

12345678910111213141516
  1. #!/usr/bin/env python
  2. import boto3
  3. import json
  4. TABLE_NAME='elaborate_employee_table'
  5. client = boto3.client('dynamodb')
  6. response = client.update_item(
  7. TableName=TABLE_NAME,
  8. Key={'id': {'N': '30'}},
  9. UpdateExpression='SET #ca = #ca + :val',
  10. ExpressionAttributeValues={':val': {'N': '120'}},
  11. ExpressionAttributeNames={'#ca': 'count_accessed'},
  12. ReturnValues='UPDATED_NEW')
  13. print(json.dumps(response['Attributes'], indent=4))