how to put an Item in aws DynamoDb using aws Lambda with python

前端 未结 3 990
闹比i
闹比i 2021-02-01 01:50

Using python in AWS Lambda, how do I put/get an item from a DynamoDB table?

In Node.js this would be something like:

dynamodb.getItem({
    \"Key\": {\"f         


        
3条回答
  •  遇见更好的自我
    2021-02-01 01:59

    Using latest AWS SDK

    import boto3
    
    def lambda_handler(event, context):
        # this will create dynamodb resource object and
        # here dynamodb is resource name
        client = boto3.resource('dynamodb')
    
        # this will search for dynamoDB table 
        # your table name may be different
        table = client.Table("dynamoDB")
        print(table.table_status)
    
        table.put_item(Item= {'id': '34','company':  'microsoft'})
    

    If your are using AWS you can use this code sample, only you have to give permissions to this lambda function, you can find details in link

提交回复
热议问题