CLI Reference
SQLFluff provides a comprehensive command-line interface for linting, fixing, and parsing SQL files.
Available Commands
| Command | Description |
|---|---|
dialects | Show the current dialects available. |
fix | Fix SQL files. PATH is the path to a sql file or directory to lint. This can be either a file (path/to/file.sql), a path (directory/of/sql/files), a single (-) character to indicate reading from stdin or a dot/blank (./) which will be interpreted like passing the current working directory as a path argument. |
format | Autoformat SQL files. This effectively force applies sqlfluff fix with a known subset of fairly stable rules. Enabled rules are ignored, but rule exclusions (via CLI) or config are still respected. PATH is the path to a sql file or directory to lint. This can be either a file (path/to/file.sql), a path (directory/of/sql/files), a single (-) character to indicate reading from stdin or a dot/blank (./) which will be interpreted like passing the current working directory as a path argument. |
lint | Lint SQL files via passing a list of files or using stdin. PATH is the path to a sql file or directory to lint. This can be either a file (path/to/file.sql), a path (directory/of/sql/files), a single (-) character to indicate reading from stdin or a dot/blank (./) which will be interpreted like passing the current working directory as a path argument. Linting SQL files: sqlfluff lint path/to/file.sql sqlfluff lint directory/of/sql/files Linting a file via stdin (note the lone - character): cat path/to/file.sql |
parse | Parse SQL files and just spit out the result. PATH is the path to a sql file or directory to lint. This can be either a file (path/to/file.sql), a path (directory/of/sql/files), a single (-) character to indicate reading from stdin or a dot/blank (./) which will be interpreted like passing the current working directory as a path argument. |
render | Render SQL files and just spit out the result. PATH is the path to a sql file. This should be either a single file file (path/to/file.sql) or a single (-) character to indicate reading from stdin. |
rules | Show the current rules in use. |
version | Show the version of sqlfluff. |
Quick Start
bash
# Lint SQL files
sqlfluff lint path/to/file.sql
# Fix violations automatically
sqlfluff fix path/to/file.sql
# Check available dialects
sqlfluff dialects