GithubHelp home page GithubHelp logo

ammfat / chinook-etl Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 180 KB

A project to create an ETL pipeline that will extract data from the Chinook database, transform the data, and load the data into a Google Cloud Platform (GCP) BigQuery data warehouse. The data warehouse will be used to analyze the data and answer business questions.

Dockerfile 2.40% Python 97.60%

chinook-etl's Introduction

Chinook ETL

Project Description

This is an ETL (Extract, Transform, Load) project that uses the Chinook database as the data source.

The Chinook database is a sample database that represents a digital media store. The database contains information about the artists, songs, and albums from the music store, as well as information on the store's employees, customers, and the customers purchases.

Project Goal

The goal of this project is to create an ETL pipeline that will extract data from the Chinook database, transform the data, and load the data into a Google Cloud Platform (GCP) BigQuery data warehouse. The data warehouse will be used to analyze the data and answer business questions.

Data Source Setup

  1. Go to data/ directory.

  2. Login to your local PostgreSQL.

  3. Dump the Chinook SQL schema by running:

    \i chinook_pg.sql
    
  4. To check if the database is created, run the following command:

    SELECT tablename FROM pg_catalog.pg_tables 
    WHERE schemaname != 'pg_catalog' 
    AND schemaname != 'information_schema';
    

    Ensure there are 11 tables listed.

GCP Setup

Coming Soon...

Airflow Installation Setup

  1. Set up virtual environment and install dependencies.

    python3 -m venv venv
    source venv/bin/activate
    
  2. Setup environment variables.

    echo -e "AIRFLOW_UID=$(id -u)\nAIRFLOW_GID=0" > .env
    
  3. Add Airflow's internal Postgres and GCP resources to the .env. Follow .env.example for reference.

  4. Run docker container for Airflow.

    docker-compose up --build -d
    
  5. Go to Airflow Web UI at http://localhost:8080/ to ensure the container is running.

Airflow Connections

To connect Airflow with external system, we need to setup connections on Airflow.

  1. On http://localhost:8080, go to Admin > Connections. Add Google Cloud connection type.

    • Conn Id: google_cloud_conn_id
    • Conn Type: Google Cloud Platform
    • Project Id: <your-project-id>
    • Keyfile Path: /creds/<your-sa-keyfile>.json
    • Scopes: https://www.googleapis.com/auth/cloud-platform
  2. Add another connection for the local PostgreSQL.

    • Conn Id: postgres_conn_id
    • Conn Type: Postgres
    • Host: <your-local-ip> (e.g.: 192.x.x.x)
    • Schema: <your-local-postgres-schema>
    • Login: <your-local-postgres-username>
    • Password: <your-local-postgres-password>
    • Port: 5432

Run Airflow DAG

Go to http://localhost:8080 to turn on the DAG.

The DAG scheduled to run @monthly from inclusive range of 2009-01-01T05:00 to 2013-12-01T05:00.

Acknowledgements

  • ETL Flatfile Airflow by @okzapradhana

  • Chinook Database by @lerocha

chinook-etl's People

Contributors

ammfat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.