|
|
@@ -1,5 +1,8 @@
|
|
|
import boto3
|
|
|
+import json
|
|
|
|
|
|
+
|
|
|
+# use Reource
|
|
|
def put_hehe(name, year, dynamodb=None):
|
|
|
if not dynamodb:
|
|
|
dynamodb = boto3.resource('dynamodb')
|
|
|
@@ -13,6 +16,19 @@ def put_hehe(name, year, dynamodb=None):
|
|
|
)
|
|
|
return response
|
|
|
|
|
|
+# use Client
|
|
|
+def updata_ddb(name,msg,alias):
|
|
|
+ client = boto3.client('dynamodb')
|
|
|
+ table.update_item(TableName='hehe',
|
|
|
+ Key={'mykey': {'S':name}},
|
|
|
+ UpdateExpression='SET name = :name, alias = :alias',
|
|
|
+ ExpressionAttributeValues={
|
|
|
+ ':name': {
|
|
|
+ 'S': msg},
|
|
|
+ ':alias':{
|
|
|
+ 'S': alias}
|
|
|
+ })
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
movie_resp = put_hehe('cxy','8848')
|