sql-insight-cli
A command-line interface to sql-insight — format, normalize, and extract tables / operations / lineage from SQL.
Installation
Build from source:
Skip the compile — fetch the prebuilt sql-insight binary attached to
the GitHub Release (cargo-binstall
required):
Or download the archive for your platform directly from Releases (Linux musl x86_64/aarch64, macOS x86_64/aarch64, Windows x86_64). Each archive is signed with GitHub Artifact Attestations — verify the download:
Commands
format— re-emit SQL in a standardized layout: single-line by default, or multi-line indented with--pretty(comments are not preserved — the parser does not retain them in the AST).normalize— abstract literals to placeholders (--unify-in-list/--unify-valuescollapse repetitive shapes;--alphabetize-insert-columnssorts INSERT column lists, only with--unify-values).extract crud— tables bucketed by Create / Read / Update / Delete.extract table-ops— table-level reads / writes / lineage per statement.extract column-ops— the same at column granularity, with lineage kinds.
Input
Every command takes the SQL one of four ways (mutually exclusive):
- an inline argument —
sql-insight format "SELECT 1" --file <path>— read it from a file- piped stdin —
echo "SELECT 1" | sql-insight format --interactive/-i— a REPL with line editing and history (↑/↓, Ctrl-R); enter statements terminated by;, exit withexit/quit/ Ctrl-D (Ctrl-C clears the in-progress statement)
With no input on an interactive terminal, the command errors rather than guessing.
Examples
Shell completions and man page
The CLI can print a static shell-completion script or its man page to stdout — the same subcommands packagers call at install time.
Shell completions:
# bash
# zsh (needs a dir on $fpath; add e.g. `fpath=(~/.zsh/completions $fpath)` to ~/.zshrc)
# fish
Supported shells: bash, zsh, fish, powershell, elvish.
Man page:
# read it directly
|
# or install per-user (add ~/.local/share/man to MANPATH if needed)
Options (extract commands)
--dialect <name> is available on every command (format / normalize /
extract) — parse under a specific dialect (default generic). The options
below are specific to extract:
--format <text|json>—jsonemits one array of per-statement results.--ddl-file <path>— a DDL file (CREATE TABLEs) to resolve against; enables catalog-aware analysis (canonicalized identities, strict columns).--default-schema/--default-catalog— search-path-style fill for bare query references.--casing <upper|lower|insensitive|sensitive>(and per-class--casing-table/--casing-table-alias/--casing-column) — override the dialect's identifier casing.
Supported SQL Dialects
Via sqlparser-rs: Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, Microsoft SQL Server, ClickHouse, BigQuery, ANSI, DuckDB, Databricks, Oracle. See the sqlparser-rs docs for details.
Contributing
Contributions to sql-insight are welcome! Whether it's adding new
features, fixing bugs, or improving documentation, feel free to fork
the repository and submit a pull request.
License
MIT — see LICENSE.txt.