简体   繁体   中英

Lambda function boto3 python

When i try to test my lambda functions it updates my dynamodb table however it also gives me extra information i don't want. I just want the visit numbers. Does anyone know how to do that?

import boto3

import json
def lambda_handler(event, context):

    dynamodb = boto3.client('dynamodb')
    response = dynamodb.update_item(
    TableName='countercv', 
    Key={
    'url':{'S': "jakejohnson.com"}
    },
    UpdateExpression='SET visits = visits + :inc',
    ExpressionAttributeValues={
    ':inc': {'N': '1'}
},
ReturnValues="UPDATED_NEW"
)

print("UPDATING ITEM")
return(response)

Try this:

return int(response["Attributes"]["visits"]["N"])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM