Skip to main content

SQLFluff

The SQL Linter for Humans

PyPi Version PyPi License PyPi Python Versions PyPi Status PyPi Downloads

GitHub Workflow Status Documentation Linting and formatting: Ruff Docker Pulls Gurubase

SQLFluff is a 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.

Table of Contents

  1. Dialects Supported
  2. Templates Supported
  3. VS Code Extension
  4. Getting Started
  5. Documentation
  6. Releases
  7. SQLFluff on Slack
  8. SQLFluff on Twitter
  9. Contributing
  10. Sponsors

Dialects Supported

Although SQL is reasonably consistent in its implementations, there are several different dialects available with variations of syntax and grammar. SQLFluff currently supports the following SQL dialects (though perhaps not in full):

We aim to make it easy to expand on the support of these dialects and also add other, currently unsupported, dialects. Please raise issues (or upvote any existing issues) to let us know of demand for missing support.

Pull requests from those that know the missing syntax or dialects are especially welcomed and are the best way for you to get support added. We are happy to work with any potential contributors on this to help them add this support. Please raise an issue first for any large feature change to ensure it is a good fit for this project before spending time on this work.

Templates Supported

SQL itself does not lend itself well to modularity, so to introduce some flexibility and reusability it is often templated as discussed more in our modularity documentation.

SQLFluff supports the following templates:

Again, please raise issues if you wish to support more templating languages/syntaxes.

VS Code Extension

We also have a VS Code extension:

Getting Started

To get started, install the package and run sqlfluff lint or sqlfluff fix.

$ 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 📜 🎉!

If you want the optional Rust-backed parser and lexer, install the rs extra:

$ pip install sqlfluff[rs]

On supported CPython 3.10+ platforms this installs a prebuilt ABI3 wheel. If no wheel is published for your platform, pip falls back to building sqlfluffrs from source, which requires a Rust toolchain and a working C/C++ build setup. The easiest way to install Rust is with rustup.

Alternatively, you can use the Official SQLFluff Docker Image or have a play using SQLFluff online.

For full CLI usage and rules reference, see the SQLFluff docs.

Documentation

For full documentation visit docs.sqlfluff.com. This documentation is generated from this repository so please raise issues or pull requests for any additions, corrections, or clarifications.

Releases

SQLFluff adheres to Semantic Versioning, so breaking changes should be restricted to major versions releases. Some elements (such as the python API) are in a less stable state and may see more significant changes more often. For details on breaking changes and how to migrate between versions, see our release notes. See the changelog for more details. If you would like to join in, please consider contributing.

New releases are made monthly. For more information, visit Releases.

SQLFluff on Slack

We have a fast-growing community on Slack, come and join us!

SQLFluff on Twitter

Follow us on Twitter @SQLFluff for announcements and other related posts.

Contributing

We are grateful to all our contributors. There is a lot to do in this project, and we are just getting started.

If you want to understand more about the architecture of SQLFluff, you can find more here.

If you would like to contribute, check out the open issues on GitHub. You can also see the guide to contributing, including the pull request acceptance principles and AI-assisted contribution expectations.

Sponsors

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

Metadata

Release files for sqlfluff 4.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlfluff 4.5.0
File Size Uploaded Provenance Actions
sqlfluff-4.5.0.tar.gz 1.2 MB Without provenance Details for sqlfluff-4.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlfluff 4.5.0
File Interpreter ABI Platform Actions
sqlfluff-4.5.0-py3-none-any.whl Python 3 none any Details for sqlfluff-4.5.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / sqlfluff-4.5.0.tar.gz

Download URL sqlfluff-4.5.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
0b0d5b2cca03e7d138b8d899249fed5fa54083e407bbd161449c0b30f901b7b8
BLAKE2b-256 checksum
How to use checksums
e6376fa8831fad5ffda6e5d3c2629b4c9ed1a4e480b4d8c9f127f132463d6d75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sqlfluff-4.5.0-py3-none-any.whl

Download URL sqlfluff-4.5.0-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
471a9abcad8061e36b69f711a6d89393241e30f9d1e0869f79965c0ae2c889c7
BLAKE2b-256 checksum
How to use checksums
f3de78c2f6d023a2dada127baf9a41a7186707d500de89947dd7259d33700bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for sqlfluff 4.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page