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 forMySQLserver andX-RapidAPI-Keyfrom 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 virtualenvAfter unzip the project, create a virtual environment with the following:
cd ETL_SuMP
virtualenv venvThen active the virtual environment and install the packages:
# For Mac or Linux
source venv/bin/activate
# For windows
venv\Scripts\activate.batInstall python packages to run project effectively:
pip install -r requirements.txtConfigure 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.pyRun project:
python src\main.pyEnter your location to fetch data:
Enter your location: londonYour 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 -vRun test with keywords( Examples: get,extract,transform,error):
pytest -k keywords -vRun to see coverage all project results:
coverage run -m pytest- Apply in
city_dimtable. - Replace attribute from old record by new record with same
city_id
- Apply in
weather_facttable. - Record have
current_flagcolumn to monitor the current weather of city. - When new weather datas is inserted, its
current_flagwill beYand 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 namein the file with your prefername.