Python ETL Pineline craws data from Weather Forecast, transforms and loads to MySQL.
Authors: Bijeck
- Mock
- MySQL
- CI Python Code Validation
- Dimensional Model
- Pytest
Project uses a number of open source projects to work properly:
- MySQL - For run sql query and store data
- Python - Main programming language that lets project run effectively.
- MySQL Workbench - Manipulate with database, and show data
You should sign up your account in RapiAPI and subcribe to Weather Map API.
mock
: contains mock data for testingsrc
: contains source filessrc/etl
: contains etl filestests
: contains tests filestests/etl
: contains etl tests filesconfig.json
: contains configuration forMySQL
server andX-RapidAPI-Key
from Weather Map APIrequirements.txt
: list python requirement packages.github/workflows/python-app.yml
: file for run CI in githubdatabase.sql
: database scriptweather_schema.png
: database weather schema
Be Sure you have Virtulenv installed if not running below:
pip install virtualenv
After unzip the project, create a virtual environment with the following:
cd ETL_SuMP
virtualenv venv
Then active the virtual environment and install the packages:
# For Mac or Linux
source venv/bin/activate
# For windows
venv\Scripts\activate.bat
Install python packages to run project effectively:
pip install -r requirements.txt
Configure your MySQL server in config.json
:
Key | Value |
---|---|
host |
localhost |
user |
root |
password |
yourpassword |
database |
databasename |
Configure your API-key from Weather Map API in config.json
to able run appication:
Key | Value |
---|---|
X-RapidAPI-Key |
key |
Create database and table:
python src\db.py
Run project:
python src\main.py
Enter your location to fetch data:
Enter your location: london
Your location 's data will countinue get after 30 seconds. You can terminate the project by press in your keyboard:
Note:
You can terminate the project by press Ctrl + C
Run test:
pytest -v
Run test with keywords( Examples: get
,extract
,transform
,error
):
pytest -k keywords -v
Run to see coverage all project results:
coverage run -m pytest
- Apply in
city_dim
table. - Replace attribute from old record by new record with same
city_id
- Apply in
weather_fact
table. - Record have
current_flag
column to monitor the current weather of city. - When new weather datas is inserted, its
current_flag
will beY
and old record will beN
. So we can keep the historical weather data of a city.
You can use database.sql
file to create database and it contains data for you.
Note: Rename
database name
in the file with your prefername
.