Skip to main content

Installation

sqlfmt is a command-line tool that is built in Python and runs on MacOS, Linux, and Windows. If you have Python installed and are familiar with installing packages, installation is as easy as:

pip install shandy-sqlfmt[jinjafmt]

For more info and tips, read on.

Try It First

Want to test out sqlfmt on a query before you install it? Go to sqlfmt.com to use the interactive, web-based version.

Prerequisites

You will need Python 3.7-3.10 installed. You should use pipx or install into a virtual environment (maybe as a dev-dependency in your project). If you do not know how to install Python and use pipx and/or virtual environments, go read about that first.

We recommend installing sqlfmt with the jinjafmt extra (which will also install the Python code formatter, Black):

pipx install shandy-sqlfmt[jinjafmt]

But if you would prefer that we leave your jinja alone (or you'd like a lighter-weight install), you can install without the extra:

pipx install shandy-sqlfmt

Other Installation Options

You should use a virtual environment to isolate sqlfmt's dependencies from others on your system. As part of a larger Python project (like a dbt project), you should probably use a package manager like Poetry or pipenv.

With the jinjafmt extra (recommended):

poetry add -D shandy-sqlfmt[jinjafmt]

Without the jinjafmt extra:

poetry add -D shandy-sqlfmt