Skip to content

feat: dbts sql — one-shot or interactive SQL on the sandbox #5

Description

@luiul

Summary

Run SQL against the sandbox without leaving the CLI. dbts sql -q "SELECT ..." for one-shot queries (Rich-rendered table); bare dbts sql opens a REPL.

Why

The most common manual context-switch in the dev loop today: after every dbts build, you SELECT * to sanity-check the result — currently means switching to Snowsight or maintaining a separate snowsql config. dbts sql already has the right target, role, and warehouse.

Sketch

  • dbts sql -q "..." — execute, render rows as a Rich table, exit.
  • dbts sql -f file.sql — read query from file.
  • dbts sql — REPL (multiline, history, semicolon-terminated). Either shell out to snowsql if installed, or use prompt_toolkit for a small interactive loop.
  • --target flag like the dbt pass-throughs (default sandbox).
  • --limit N (default 100) so accidental SELECT * from a billion-row table doesn't hang the terminal.

Where it'd live

  • New module src/dbts/sql_cmd.py (avoid shadowing stdlib sql).
  • Reuse snowflake.connect / run_sql.
  • Output uses rich.table.Table (same as clone.status).

Effort

Small for the one-shot path, medium for the REPL.

Tier

Tier 1 — recommended (highest-frequency missing dev action).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions