Wednesday, 8 March 2017

Configure AWS Dynamo DB from Web Server through Python , Get data from your AWS Dynamo DB through Python

Amazon Dynamo DB is a fully managed No SQL database service that provides fast and predictable performance with seamless scalability.

With Dynamo DB, you can create database tables that can store and retrieve any amount of data, and serve any level of request traffic.

In this blog , we will know how can we access Dynamo DB from Web Server and read the data from Dynamo DB table.

Prerequisites :  

1) Jet Brains PyCharm Community Edition (Version 3+)

Python and Dynamo DB : 

Step1 : Create AWS Account from AWS Official Website (

Step2 : Go To IAM Console and get the Dynamo DB Access Key and Secret Key from your own                    Account .

 Step3 :  Go To Users and copy your Access Key and Secret Key  .

Step4 :  Provide the  AWS Config file and AWS Credentuials file.
              Go To Command Prompt and provide details.
               Type aws configure  in command prompt

               Credentials File -> [default]
                                              aws_access_key_id = *********************
                                              aws_secret_access_key = ***************************

               Config File ->        [default]


Step5 :    Establish Connection from PyCharm and get the DynamoDb service to read the data.



               To achieve this let's start coding from PyCharm 

Step6 :   Open PyCharm->Create a Python File 
                Write the below code 

               import boto3
      dynamodb = boto3.resource("dynamodb", region_name='us-west-2')

        We are done.
            Now we will get the target service as dynamodb.ServiceResource().
        Let's start coding to read the Dynamo Db data.
                      Read Data from DynamoDb Table : 

Step7 :   Suppose, 
               Let us Assume that we have a table named Employee_details , Attributes as UserName
           If I want to get data of a particular user I would write the code as follows.
           Reference Code :
                  import boto3
          dynamodb = boto3.resource('dynamodb', region_name='us-west-2')
          table = dynamodb.Table('Employee_details')

          user_name = 'SrikarN'
          response = table.get_item(
'UserName': user_name,
print(dynamodb) item = response['Item'] print(item) print("GetItem succeeded:")
  Run the program ...

   OUTPUT : 

   So this how you can read the data from the AWS DynamoDB Table .

   Thank You ,
   Srikar Nagadevara,
   Mouri Tech Pvt Limited

1 comment: