DEV Community

Cover image for How to connect to DynamoDB with Python using Docker Compose? | Boilerplate, Starter Pack 🐳
Rohan Sawant
Rohan Sawant

Posted on

How to connect to DynamoDB with Python using Docker Compose? | Boilerplate, Starter Pack 🐳

A Docker and Docker Compose starter kit to help you get started with AWS DynamoDB quickly.

Use this as a boilerplate for your next project, I already did!

GitHub logo CT83 / DynamoDB-Python-Docker-Compose-Starter-Kit

An AWS DynamoDB with Python using Docker and Docker Compose Starter kit to help you hit the ground running.

alt text

DynamoDB-Python-Docker-Compose-Starter-Kit

A Docker and Docker Compose starter kit to help you get started with AWS DynamoDB quickly.

Use this as a boilerplate for your next project, I already did!

I am assuming you are already familiar with Docker and Docker Compose, so I'll get right to it.

What is DynamoDB?

Amazon DynamoDB is a fully managed proprietary NoSQL database service that supports key-value and document data structures.

What does the app.py do?

  1. The app.py uses Facebook's Hydra Config Management to pickup the desired configuration, from the .yml file and loads it.
  2. Then a connection is made to a DynamoDB Instance.
  3. Some basic database operations are performed using the PynamoDB library.

How to run?

There are 2 modes in which you can run the app.py in.

1. Local DynamoDB Mode -

Here, A Local Instance of DynamoDB is spun up using, Docker and Amazon's Official Local DynamoDB Image.

All…

I am assuming you are already familiar with Docker and Docker Compose, so I'll get right to it.

What is DynamoDB?

Amazon DynamoDB is a fully managed proprietary NoSQL database service that supports key-value and document data
structures.

What does the app.py do?

  1. The app.py uses Facebook's Hydra Config Management to pickup the desired configuration, from the .yml file and loads it.
  2. Then a connection is made to a DynamoDB Instance.
  3. Some basic database operations are performed using the PynamoDB library.

How to run?

There are 2 modes in which you can run the app.py in.

1. Local DynamoDB Mode -

Here, A Local Instance of DynamoDB is spun up using, Docker and Amazon's Official Local DynamoDB Image.

All the database operations are then performed on this local instance.

  1. docker-compose up --build

2. AWS DynamoDB Mode

Here, the app.py will connect to the AWS DynamoDB Instance, this is how your code might run in the production.
In this mode you are expected to

  1. Create a Python Virtual Environment
  2. pip install -r requirements.txt
  3. Create an .env file with your AWS Credentials, like example.env.
  4. Replace docker with aws in the env-config.yml.
  5. Run using python app.py

That is it!

This should help you get started really quickly!

πŸ‹ + πŸ“€ + 🐍 = πŸ€“

Top comments (0)