Thursday, 8 October 2020

Boto3: Part 1

 Uploading data on DynamoDB using Boto3.

Create Table.

Search for DynamoDB service in AWS console and click on "Create table"

Enter the below details and click "Create"

Table is created.


Enter the data manually by clicking on "create item" manually


and click on "Save"


Now update the table using Boto3 

code :upload_db.py

import boto3

db=boto3.resource('dynamodb')
table=db.Table('employees')
table.put_item(
    Item={
        'emp_id':"2",
        'Name'"Charvik",
        'Age':"4"
    }
)

run the code and check console for successful update of table.

Get the data from table

# Get the data from table.
response=table.get_item(
    Key={
        "emp_id":"1"
    }
)
print(response["Item"])


When you run above code , you can see the output.

Refer for code in my github account: https://github.com/krishhmomdad/Boto

Thank you for reading πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘

No comments:

Post a Comment