import boto3 import json # use Reource def put_hehe(name, year, dynamodb=None): if not dynamodb: dynamodb = boto3.resource('dynamodb') table = dynamodb.Table('hehe') response = table.put_item( Item={ 'name': name, 'year': year, } ) 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') print("Put movie succeeded:")