Answers for "get data from dynamodb using boto3"

0

get item dynamodb boto3

def get_movie(title, year, dynamodb=None):
    if not dynamodb:
        dynamodb = boto3.resource('dynamodb', endpoint_url="http://localhost:8000")

    table = dynamodb.Table('Movies')

    try:
        response = table.get_item(Key={'year': year, 'title': title})
    except ClientError as e:
        print(e.response['Error']['Message'])
    else:
        return response['Item']
Posted by: Guest on April-29-2021
0

get data from dynamodb using boto3

import boto3

db = boto3.resource('dynamodb')
table = db.Table('Register')#Replace register with name of your table

#Adding items to your table 
# table.put_item(
#     Item = {
#         'Name':'Kim',
#         'Surname':'Ndlovu' 
#     }
# )

#Getting items from the table
response = table.scan()['Items']
print (response)
Posted by: Guest on January-20-2022

Python Answers by Framework

Browse Popular Code Answers by Language