Browse Source

add py/DynamoDB-UpdateItem.py.
Update_Item DynamoDB

xdc 5 năm trước cách đây
mục cha
commit
7aa2cedc31
1 tập tin đã thay đổi với 21 bổ sung0 xóa
  1. 21 0
      py/DynamoDB-UpdateItem.py

+ 21 - 0
py/DynamoDB-UpdateItem.py

@@ -0,0 +1,21 @@
+import boto3
+
+    
+def increase_rating(keya,dynamodb=None):
+    if not dynamodb:
+        dynamodb = boto3.resource('dynamodb')
+
+    table = dynamodb.Table('hehe')
+    
+    response = table.update_item(
+        Key={'name': keya},
+        UpdateExpression="set alias=:val",
+        ExpressionAttributeValues={
+            ':val': 'hehe'},
+        ReturnValues="UPDATED_NEW")
+    return response
+   
+ 
+if __name__ == '__main__':
+    update_response = increase_rating("cxy")
+    print("Update movie succeeded:")