Implementing a Simple DynamoDB Application

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

In this lab, we will implement a simple application that accepts CSV files, converts them to DynamoDB JSON, and puts the data into a table with the same name as the file. In the solution video, we will walk through how to reach these goals with the Python Boto3 SDK.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Write Application Code

Write code utilizing the AWS SDK for the language of your choice to convert the CSV file with the field delimiter of Ԙ and quotation character of ԡ to the DynamoDB JSON format as seen below. Also include table creation for tables that share the name of the provided files without the file extension, and write the converted files to the appropriate tables.

Data Conversion Sample

So this:

"ԡ12ԡԘԡGiant Sandԡ"

Becomes:

{
    'id': {
        'N': '12'
    },
    'name': {
        'S': 'Giant Sand'
    }
},

Hint: The code can be found on GitHub.

Log In to the Provided EC2 Instance and Run the Code
  1. Log in to the provided EC2 instance using the provided IP address and credentials.
  2. Write your code to a file named pinehead_data_util and configure to be able to run as a command.
  3. Run your code!
Verify the Data Migration to AWS
  1. Log in to the AWS Management Console for the lab account with the provided credentials.
  2. Navigate to DynamoDB.
  3. Verify there are three tables and the appropriate data loaded correctly.

Additional Resources

You are working for a company that takes contracts to perform cloud implementation projects. The company has received a contract to assist migrating a vinyl-only online record store from an on-premises application architecture that is backed by a relational database. We have been provided with data that needs to be stored in DynamoDB tables. This data is contained in three files: artist.csv, album.csv, and track.csv. These files use a custom CSV dialect with a delimiter of Ԙ and a quotation character of ԡ.

Our team has been tasked with creating a utility to ingest the comma-separated value data that has been provided to DynamoDB tables with the same names as the files. The utility should output the number of items entered into the DynamoDB table, as well as any records that failed to be put in the table and, where possible, the reason for the failure.

Create artist, album, and track tables and ingest the data from the provided CSV files:

pinehead_data_util -f artist.csv
pinehead_data_util -f album.csv
pinehead_data_util -f track.csv

Or:

pinehead_data_util -f artist.csv,album.csv,track.csv

The code used for the solution in the lab can be found on GitHub.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?