CLI Reference

sqlfluff

Sqlfluff is a modular sql linter for humans.

sqlfluff [OPTIONS] COMMAND [ARGS]...

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.

sqlfluff fix [OPTIONS] [PATHS]...

Options

--exclude-rules <exclude_rules>

Exclude specific rules. For example specifying –exclude-rules L001 will remove rule L001 (Unnessesary trailing whitespace) from the set of considered rules. This could either be the whitelist, or the general set if there is no specific whitelist. Multiple rules can be specified with commas e.g. –exclude-rules L001,L002 will exclude violations of rule L001 and rule L002.

--rules <rules>

Narrow the search to only specific rules. For example specifying –rules L001 will only search for rule L001 (Unnessesary trailing whitespace). Multiple rules can be specified with commas e.g. –rules L001,L002 will specify only looking for violations of rule L001 and rule L002.

--templater <templater>

The templater to use (default=jinja)

--dialect <dialect>

The dialect of SQL to lint (default=ansi)

-n, --nocolor

No color - if this is set then the output will be without ANSI color codes.

-v, --verbose

Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv.

-f, --force

skip the confirmation prompt and go straight to applying fixes. Use this with caution.

Arguments

PATHS

Optional argument(s)

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 | sqlfluff lint - echo ‘select col from tbl’ | sqlfluff lint -
sqlfluff lint [OPTIONS] [PATHS]...

Options

--exclude-rules <exclude_rules>

Exclude specific rules. For example specifying –exclude-rules L001 will remove rule L001 (Unnessesary trailing whitespace) from the set of considered rules. This could either be the whitelist, or the general set if there is no specific whitelist. Multiple rules can be specified with commas e.g. –exclude-rules L001,L002 will exclude violations of rule L001 and rule L002.

--rules <rules>

Narrow the search to only specific rules. For example specifying –rules L001 will only search for rule L001 (Unnessesary trailing whitespace). Multiple rules can be specified with commas e.g. –rules L001,L002 will specify only looking for violations of rule L001 and rule L002.

--templater <templater>

The templater to use (default=jinja)

--dialect <dialect>

The dialect of SQL to lint (default=ansi)

-n, --nocolor

No color - if this is set then the output will be without ANSI color codes.

-v, --verbose

Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv.

Arguments

PATHS

Optional argument(s)

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.

sqlfluff parse [OPTIONS] PATH

Options

--exclude-rules <exclude_rules>

Exclude specific rules. For example specifying –exclude-rules L001 will remove rule L001 (Unnessesary trailing whitespace) from the set of considered rules. This could either be the whitelist, or the general set if there is no specific whitelist. Multiple rules can be specified with commas e.g. –exclude-rules L001,L002 will exclude violations of rule L001 and rule L002.

--rules <rules>

Narrow the search to only specific rules. For example specifying –rules L001 will only search for rule L001 (Unnessesary trailing whitespace). Multiple rules can be specified with commas e.g. –rules L001,L002 will specify only looking for violations of rule L001 and rule L002.

--templater <templater>

The templater to use (default=jinja)

--dialect <dialect>

The dialect of SQL to lint (default=ansi)

-n, --nocolor

No color - if this is set then the output will be without ANSI color codes.

-v, --verbose

Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv.

--recurse <recurse>

The depth to recursively parse to (0 for unlimited)

-c, --code-only

Output only the code elements of the parse tree.

Arguments

PATH

Required argument

rules

Show the current rules is use.

sqlfluff rules [OPTIONS]

Options

--exclude-rules <exclude_rules>

Exclude specific rules. For example specifying –exclude-rules L001 will remove rule L001 (Unnessesary trailing whitespace) from the set of considered rules. This could either be the whitelist, or the general set if there is no specific whitelist. Multiple rules can be specified with commas e.g. –exclude-rules L001,L002 will exclude violations of rule L001 and rule L002.

--rules <rules>

Narrow the search to only specific rules. For example specifying –rules L001 will only search for rule L001 (Unnessesary trailing whitespace). Multiple rules can be specified with commas e.g. –rules L001,L002 will specify only looking for violations of rule L001 and rule L002.

--templater <templater>

The templater to use (default=jinja)

--dialect <dialect>

The dialect of SQL to lint (default=ansi)

-n, --nocolor

No color - if this is set then the output will be without ANSI color codes.

-v, --verbose

Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv.

version

Show the version of sqlfluff.

sqlfluff version [OPTIONS]

Options

--exclude-rules <exclude_rules>

Exclude specific rules. For example specifying –exclude-rules L001 will remove rule L001 (Unnessesary trailing whitespace) from the set of considered rules. This could either be the whitelist, or the general set if there is no specific whitelist. Multiple rules can be specified with commas e.g. –exclude-rules L001,L002 will exclude violations of rule L001 and rule L002.

--rules <rules>

Narrow the search to only specific rules. For example specifying –rules L001 will only search for rule L001 (Unnessesary trailing whitespace). Multiple rules can be specified with commas e.g. –rules L001,L002 will specify only looking for violations of rule L001 and rule L002.

--templater <templater>

The templater to use (default=jinja)

--dialect <dialect>

The dialect of SQL to lint (default=ansi)

-n, --nocolor

No color - if this is set then the output will be without ANSI color codes.

-v, --verbose

Verbosity, how detailed should the output be. This is stackable, so -vv is more verbose than -v. For the most verbose option try -vvvv or -vvvvv.