Giter Club home page Giter Club logo

dbt-with-postgres's Introduction

DBT with Postgres

Using Python v3.8.10 on Ubuntu Linux v20.04, with Docker v20.10.8, docker-compose v1.29.2 and DBT v0.20.2.

Setup

  1. Pre-setup for Ubuntu/Debian distros

     sudo apt-get install git libpq-dev python-dev python3-pip
     sudo apt-get remove python-cffi
     sudo pip install -U cffi
     pip install cryptography~=3.4
    
  2. Create a Python virtual environment and activate it

     python3 -m venv .venv; source .venv/bin/activate
    
  3. Install libraries (upgrading pip if necessary)

     pip install -U wheel setuptools; pip install -U dbt
    
  4. Initialize DBT project and go inside it

     dbt init DBT-with-Postgres; cd DBT-with-Postgres
    
  5. Initialize Git

     git init
    
  6. Build Docker containers specified in the docker-compose.yml file

     docker-compose up --build -d
    
  7. Copy over the Postgres JDBC driver to the jars directory in SPARK_HOME=/usr/local/spark

     docker cp drivers/postgresql-42.2.23.jar dbt-with-postgres_pyspark-notebook_1:/usr/local/spark/jars/
    
  8. Create a profiles.yml file in the ~/.dbt/ directory and add the following.

    darmadia:  # the profile_name, typically a company name, with one profile for each warehouse
    target: dev-postgres-dest
    outputs:
        dev-postgres-dest:
        type: postgres  # type of connection
        host: localhost  
        user: destdb1
        password: destdb1
        port: 5434
        dbname: destdb
        schema: stage
        threads: 4
        keepalives_idle: 0
        # search_path: [optional, override the default postgres search_path]
        # role: [optional, set the role dbt assumes when executing queries]
        # sslmode: [optional, set the sslmode used to connect to the database]

    Run the debug command to test connection to database

     dbt debug
    
  9. Run the example models to confirm that setup is successful

     dbt run
    

dbt-with-postgres's People

Contributors

ismaildawoodjee avatar

Watchers

 avatar  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.