How to Create a DynamoDB Table Using Boto3 and Python!

Sharon Johnson
4 min readApr 15, 2023

--

Photo by James Harrison on Unsplash

Lets get started with the “what is”!

What is DynamoDB? Amazon DynamoDB is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale. DynamoDB offers built-in security, continuous backups, automated multi-Region replication, in-memory caching, and data import and export tools.

What is Boto3?(AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2.

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics developed by Guido van Rossum. It was originally released in 1991.

So with this project, I’m creating a DynamoDB table to list out my 10 favorite ice cream brands and flavors using boto3 and python.

A few things will be needed to achieve this, first you will need to create an AWS account, then choose a IDE (An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently. It increases developer productivity by combining capabilities such as software editing, building, testing, and packaging in an easy-to-use application). I will be using AWS Cloud9. (you can click onto the underline words and be directed to AWS site for instructions).

Once you have your account set up and your Cloud9 running, you will need to navigate to Cloud9, click on FILE, then Save As, name your file make sure you save it under the folder you created as a .py file.

Open up a new terminal and put in a map to your directory you will be using. You will need to add in the following script

pip3 install boto3

pip3 install awscli

aws configure

You will be prompt here to add in your credentials, enter in your region and your output format(json).

Ok now I can start writing my script to create the DynamoDB table for my “Favorite Ice Cream”

Once you click onto run you should get the following return Table Created!

So lets navigate to the console and search DynamoDB and see if the table was actually created using this script

The table was successfully created!

So from here I will create a script to list out my favorite ice cream brand and flavors. I did create another .py file to add to the table.

As you can see this script gave me a return with my “Favorite Ice Cream” listing out my favorite brand and flavors!!!! Also this script allowed me to scan out my table.

Scanned table return using the above script!

Ok lets navigate back to the console and see if it actually listed out my “Favorite Ice Cream”, the brand and flavors

There you go!! The project is completed and now lets push it to GITHUB!

Photo by Rubaitul Azad on Unsplash

By the way don’t forget to remove your access key and secret keys, I forgot and it costed me a lot of time getting it resolve.

https://github.com/SharonRJohnson/Sharon-Gold-LUIT

--

--

No responses yet