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.
pip install dbtcopyRequires Python 3.9+ and dbt already installed in your environment.
# 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/profilesAll arguments after the model name are passed directly to dbt compile.
- Runs
dbt compile --select <model>(output shown by default, use--quietto hide) - Finds
<model>.sqlintarget/compiled/recursively - Reads the file and copies the contents to your clipboard
- Prints a confirmation:
Copied 42 lines to clipboard (target/compiled/.../model.sql) - On compile failure, shows the actual dbt error message
Clipboard works on:
- macOS —
pbcopy - Linux (X11) —
xclip - Linux (Wayland) —
wl-copy - WSL / Windows —
clip.exe
If no clipboard tool is found, the SQL is printed to stdout as a fallback.
MIT