In this lab, you will learn how to write a script that populates an existing RDS table with mock data. You’ll take a look at `pandas` and `Faker`, two Python libraries that will allow you to easily generate data and add it to your MySQL database.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Record the Public DNS of Your RDS Instance
- Navigate to the RDS service.
- Navigate to your instances and view the RDS instance generated for this lab.
- Find the instance details and record the public DNS for use later in the lab.
- Create a Cloud9 Development Environment
- Navigate to the Cloud9 service.
- Create a development environment with an SSH connection.
- Connect to your new Cloud9 development environment.
- Install Dependencies for Your Solution
If following the provided solution and using Python, use
pip install
to install thepandas
,Faker
,collections
,SQLAlchemy
,PyMySQL
, andBoto3
dependencies.- Write a Script to Populate Custom MySQL Data to Your RDS Table
From the Cloud9 file directory, create a .py script file to contain your solution code that does the following:
- Initializes Faker.
- Models your mock data.
- Initializes a DataFrame with your mock data..
- Sends your mock data to a new table in your database.
- Create a Database in Your RDS Instance to Populate with Mock Data
- From the Cloud9 console, connect to your RDS instance.
- Create an empty database to populate with mock data.
Note: Make sure the name of this database matches the database name defined in your code.
- Test Your Solution and View the Items Added to Your MySQL Database
- Run your solution script.
- Connect to your database and view the items in the table you created. You should see the generated mock data in your database.