Skip to content

Tomiwa-dev/dbtcopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbtcopy

Compile a dbt model and copy the clean SQL to your clipboard — no log noise, no thread counts, no adapter info.

dbt compile dumps a wall of logs to stdout, making it painful to grab just the SQL. dbtcopy runs the compile for you, reads the clean output from target/compiled/, and copies it straight to your clipboard.

Install

pip install dbtcopy

Requires Python 3.9+ and dbt already installed in your environment.

Usage

# Basic — compile and copy to clipboard
dbtcopy my_model

# With dbt target
dbtcopy my_model --target=prod

# With full-refresh
dbtcopy my_model --target=prod --full-refresh

# With dbt vars
dbtcopy my_model --target=prod --vars '{"start_date": "2024-01-01"}'

# Print to stdout instead of clipboard
dbtcopy my_model --print

# Copy AND print
dbtcopy my_model --print-and-copy

# Hide dbt compile output
dbtcopy my_model --quiet

# Skip compile, just grab existing compiled SQL
dbtcopy my_model --no-compile

# Specify dbt project/profiles directory
dbtcopy my_model --project-dir /path/to/project --profiles-dir /path/to/profiles

All arguments after the model name are passed directly to dbt compile.

How it works

  1. Runs dbt compile --select <model> (output shown by default, use --quiet to hide)
  2. Finds <model>.sql in target/compiled/ recursively
  3. Reads the file and copies the contents to your clipboard
  4. Prints a confirmation: Copied 42 lines to clipboard (target/compiled/.../model.sql)
  5. On compile failure, shows the actual dbt error message

Platform support

Clipboard works on:

  • macOSpbcopy
  • Linux (X11)xclip
  • Linux (Wayland)wl-copy
  • WSL / Windowsclip.exe

If no clipboard tool is found, the SQL is printed to stdout as a fallback.

License

MIT

About

Compile a dbt model and copy the clean SQL to your clipboard — no log noise, no thread counts, no adapter info.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages