Skip to content

Eben2020-hp/Introduction-to-DynamoDB

Repository files navigation

Introduction-to-DynamoDB

What is DynamoDB?

DynamoDB is a speedy and flexible NoSQL database service offered by AWS (Amazon Web Service). You can use Amazon DynamoDB to create a database table that can store and retrieve any amount of data, and serve any level of request traffic. Amazon DynamoDB automatically spreads the data and traffic for the table over a sufficient number of servers to handle the request capacity specified by the customer and the amount of data stored, while maintaining consistent and fast performance.

We will be understanding how to use Python SDK (Boto3) to perform operations in DynamoDB.

Prerequisites

Before going any further we need to download three main things:

Instructions Link
1 Download DynamoDB locally https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html
2 Download AWS CLI https://awscli.amazonaws.com/AWSCLIV2.msi
3 Install Java Runtime Environment (JRE) https://www.java.com/en/download/manual.jsp

IMPORTANT:

  • If working with Windows OS, please make sure that you have installed all the three inside the same folder.
  • If working with Linux, this will not be an issue, although it is recommended to keep DynamoDB and AWS CLI inside the same folder.

Procedure

  • STEP 1: After completing the above prerequisites, we have to next Deploy DynamoDB in our computer. For this open your Command Prompt (Preferablly Anaconda) or a terminal in your IDE. I use VSCode.

This is your Java Instance that needs to keep on running.
  • STEP 2: In a seperate terminal run the following commands to configure your credentials in order to enable authorization.

By doing this you will now be able to access your DynamoDB.
  • STEP 3: Next we will create the necessary python files. This will be used for creating the table and inserting new values. We will be using six codes to perform six different tasks, and after creating the necessary files we will be calling all the .py files using python filename.py.

    • Create Table

    • Data Creation

    • Loading Data

    • Reading Items in the Table

    • Query

We can see how we excecuted the above files and we can also see their outputs. We will be able to see all the data in out table using the *scan.py*.
  • Scan Table

We have done our initial procedure or adding Data to our table and perform basic operations.

  • STEP 4: Now we will go the extra mile and create a function that will do a simple task of turning on the sprinklers when the Temperature is greater than 25 degree Celcius.

    • Activating the Device

  • STEP 5: As shown above we have thus completed the task assigned to us. Now we can Delete the Table.

    • Delete Table


This shows us a basic idea on how to get started with DynamoDB and Python.

About

Building a NoSQL database in order to develop an Application for Smart Farming using IoT Devices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages