Skip to content

Demo DAGs that show how to run dbt Core in Airflow using Cosmos without astro-cli locally

Notifications You must be signed in to change notification settings

snhou/airflow-dbt-cosmos-demo

 
 

Repository files navigation

cosmos-demo

Prerequisites

  1. Homebrew
  2. git
  3. Python 3.9 or higher
  4. pip
  5. Docker Desktop

Environment Setup

  1. Clone this repository
git clone https://github.com/snhou/cosmos-demo-without-astro-cli.git
  1. Change into the cosmos-demo-without-astro-cli directory
cd cosmos-demo-without-astro-cli
  1. Install virtual environment
python3 -m venv venv
  1. Enter into venv
source venv/bin/activate
  1. Update pip
python3 -m pip install --upgrade pip
  1. Install dependencies
python3 -m pip install -r requirements.txt
  1. docker pull airflow image
docker pull apache/airflow:2.9.2
  1. Open Docker Desktop and run docker-compose.yaml
docker compose build
docker compose up -d

Aiflow Connection Setup

  1. Connect to postgres
  • Admin > Connections Alt text
Connection Id : airflow_metadata_db
Connection Type : Postgres
Host : host.docker.internal
Database : airflow
Login : airflow
Password : airflow
Port : 5432
  1. Trigger DAGs
  • DAGs > Actions(trigger) Alt text

Install pgcli to connect Postgres

  1. Use brew to install
brew install pgcli
  1. Use pgcli to connect postgres db
pgcli -h localhost -p 5432 -u airflow
  • pwd:airflow

Using command to check schema and tables

  • Clear window
\! clear
  • List database
\l
  • List tables
\dt
  • List all table, view,
\z
  • list schema names
\dn
  • Show now schema
SHOW SEARCH_PATH;
  • Change schema
SET search_path TO {schema name}

About

Demo DAGs that show how to run dbt Core in Airflow using Cosmos without astro-cli locally

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.2%
  • Dockerfile 2.8%