sqlfluff
๐Ÿ“œ The SQL Linter for humans

PyPI - Downloads PyPI GitHub GitHub Repo stars

SQLFluff is an open source, dialect-flexible and configurable SQL linter. Designed with ELT applications in mind, SQLFluff also works with Jinja templating and dbt. SQLFluff will auto-fix most linting errors, allowing you to focus your time on what matters.

Lint ๐Ÿงผ

SQLFluff finds issues with your SQL code and reports them back to you (and your team) automatically so that your code reviews can be more about function and less about form.

Fix ๐Ÿ› ๏ธ

SQLFluff saves time by fixing linting issues found in your code to save you time, and make it easy to have consistent and legible SQL.

Parse ๐Ÿ“œ

SQLFluff parses your SQL to catch a range of syntax issues without needing access to the database, so you can catch mistakes earlier in your development process.

Configure โš™๏ธ

SQLFluff is configurable to work with a range of SQL dialects and style choices. It has opinionated defaults, so you can get going easily, but a range of flexible configuration options to fit your local style.

Getting Started

You can get started with SQLFluff in your project today by downloading it from pypi using pip (or your favourite python package manager). For more details, check out the docs.

$ pip install sqlfluff
$ echo "  SELECT a  +  b FROM tbl;  " > test.sql
$ sqlfluff lint test.sql --dialect ansi
== [test.sql] FAIL
L:   1 | P:   1 | LT01 | Expected only single space before 'SELECT' keyword.
                       | Found '  '. [layout.spacing]
L:   1 | P:   1 | LT02 | First line should not be indented.
                       | [layout.indent]
L:   1 | P:   1 | LT13 | Files must not begin with newlines or whitespace.
                       | [layout.start_of_file]
L:   1 | P:  11 | LT01 | Expected only single space before binary operator '+'.
                       | Found '  '. [layout.spacing]
L:   1 | P:  14 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L:   1 | P:  27 | LT01 | Unnecessary trailing whitespace at end of file.
                       | [layout.spacing]
L:   1 | P:  27 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
All Finished ๐Ÿ“œ ๐ŸŽ‰!
      

Sponsors

SQLFluff is a community run, and community funded, project. We're grateful to individuals and organisations in the community who choose to support the project. If you'd like to support the project with your time, then head over to our GitHub repository and check out our contributing guide. If you are better able to support the project with funds, then you can find our sponsorship page on GitHub sponsors.

Sponsoring Organisations

The turnkey analytics stack, find out more at datacoves.com.