sql-insight-cli
A command-line interface to sql-insight — format, normalize, and extract tables / operations / lineage from SQL.
Installation
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
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.