https://github.com/sajonaro/dbt-ex
small example of how to use dbt
https://github.com/sajonaro/dbt-ex
data-modelling dbt poetry python
Last synced: 9 months ago
JSON representation
small example of how to use dbt
- Host: GitHub
- URL: https://github.com/sajonaro/dbt-ex
- Owner: sajonaro
- Created: 2025-01-08T11:33:46.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-08T14:30:50.000Z (about 1 year ago)
- Last Synced: 2025-05-05T03:16:46.489Z (9 months ago)
- Topics: data-modelling, dbt, poetry, python
- Language: PLpgSQL
- Homepage:
- Size: 89.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Useful scrips
```bash
#create symlink to ~./dbt/profile.yml
$ ln -s ~/.dbt/profiles.yml profiles.yml
```
```bash
# install dependencies (from .toml file)
$ poetry install
```
### DBT commands (ran via poetry)
```bash
# compile = dbt run
$ cd ex1
$ poetry run dbt run
# if dbt_project.yml settings have changed
$ poetry run dbt run --full-refresh
# to check validity of connections = dbt debug
$ poetry run dbt debug
# run tests = dbt test
$ poetry run dbt test
# run seed, tests, run in all in one command = dbt build
$ poetry run dbt build
```
### using [DuckDB CLI](https://duckdb.org/docs/installation/?environment=cli) to check dbt results (= query output db)
```bash
# to install DuckDBCLi
$ curl --fail --location --progress-bar --output duckdb_cli-linux-amd64.zip https://github.com/duckdb/duckdb/releases/download/v1.1.3/duckdb_cli-linux-amd64.zip && unzip duckdb_cli-linux-amd64.zip
```
```bash
# to open persisted db (in this case ex2.duckdb)
$ ./duckdb ex2.duckdb
# to see all tables in current database (while in ./dudckb session)
D show tables;
# to export table `customers` to `customers.txt` file
D COPY (SELECT * FROM customers) TO 'output.txt' (HEADER, DELIMITER ',');
```