This repository contains a simple Python script (database_pipeline_poc.py) demonstrating a basic Extract, Transform, Load (ETL) process. It serves as a proof-of-concept for automating the ingestion of data from a source (CSV file) into a structured database (SQLite) for analysis.
The goal of this project is to showcase foundational skills in:
- Data Extraction: Reading data from a common file format.
- Data Transformation: Performing basic cleaning and restructuring using Pandas.
- Data Loading: Populating a relational database table.
- SQL Querying: Retrieving and aggregating data from the database.
This demonstrates understanding of the core principles behind building automated data pipelines for research or business intelligence purposes.
This script requires Python 3 and the pandas library.
- Ensure Python 3 is installed. You can check by typing
python --versionorpython3 --versionin your terminal. - Install pandas: If you don't have pandas installed, open your terminal or command prompt and run:
pip install pandas
- Clone the repository (or download the files):
git clone https://github.com/MaxHaro/database-automation-poc cd database-automation-poc - Run the script:
python database_pipeline_poc.py
When you run the script:
- It first checks if
sample_energy_data.csvexists. If not, it creates a small sample file. - Extract: It reads the data from
sample_energy_data.csvinto a Pandas DataFrame. - Transform: It converts the 'Generation_GWh' column to 'Generation_TWh' and ensures the 'Year' column is an integer.
- Load: It creates (or replaces) an SQLite database file named
energy_data.dband loads the transformed data into a table calledannual_generation. - Query: It executes three sample SQL queries against the database and prints the results to the console, demonstrating data retrieval and aggregation.
You will see output messages indicating the progress of each step and the results of the SQL queries.
- Python 3
- Pandas: For data manipulation and reading/writing CSVs.
- SQLite3: Python's built-in module for interacting with SQLite databases.