Installation Guide
To get started with SQLFluff you'll need python and pip installed on your machine, if you're already set up, you can skip straight to Installing sqlfluff.
Installing Python
How to install python and pip depends on what operating system you're using. In any case, the python wiki provides up to date instructions for all platforms here.
There's a chance that you'll be offered the choice between python versions. Support for python 2 was dropped in early 2020, so you should always opt for a version number starting with a 3. As for more specific options beyond that, SQLFluff aims to be compatible with all current python versions, and so it's best to pick the most recent.
You can confirm that python is working as expected by heading to your terminal or console of choice and typing python --version which should give you a sensible read out and not an error.
python --version
Python 3.9.1For most people, their installation of python will come with pip (the python package manager) preinstalled. To confirm this you can type pip --version similar to python above.
pip --version
pip 21.3.1 fromIf however, you do have python installed but not pip, then the best instructions for what to do next are on the python website.
Installing SQLFluff
Assuming that python and pip are already installed, then installing SQLFluff is straightforward.
pip install sqlfluffIf 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 a wheel is not available for your platform, architecture, or Python implementation, pip falls back to building sqlfluffrs from source. In that case you will need a Rust toolchain and a working native build toolchain for your platform. The easiest way to install Rust is via rustup.
You can confirm its installation by getting SQLFluff to show its version number.
sqlfluff version
3.5.0Going further
From here, there are several more things to explore.
- To understand how SQLFluff is interpreting your file explore the
parsecommand. You can learn more about that command and more by runningsqlfluff --helporsqlfluff parse --help. - To start linting more than just one file at a time, experiment with passing SQLFluff directories rather than just single files. Try running
sqlfluff lint .(to lint every sql file in the current folder) orsqlfluff lint path/to/my/sqlfiles. - To find out more about which rules are available, see Rules Reference.
- To find out more about configuring SQLFluff and what other options are available, see Configuration.
- Once you're ready to start using SQLFluff on a project or with the rest of your team, check out Production Usage.
One last thing to note is that SQLFluff is a relatively new project and you may find bugs or strange things while using it. If you do find anything, the most useful thing you can do is to post the issue on GitHub where the maintainers of the project can work out what to do with it. The project is in active development and so updates and fixes may come out regularly.