DynamoDB-UpdateItem.py 528 B

123456789101112131415161718192021
  1. import boto3
  2. def increase_rating(keya,dynamodb=None):
  3. if not dynamodb:
  4. dynamodb = boto3.resource('dynamodb')
  5. table = dynamodb.Table('hehe')
  6. response = table.update_item(
  7. Key={'name': keya},
  8. UpdateExpression="set alias=:val",
  9. ExpressionAttributeValues={
  10. ':val': 'hehe'},
  11. ReturnValues="UPDATED_NEW")
  12. return response
  13. if __name__ == '__main__':
  14. update_response = increase_rating("cxy")
  15. print("Update movie succeeded:")