📄️ dbt (Core)
sqlfmt was built for dbt, so only minimal configuration is required. We recommend excluding your target and dbt_packages directories from formatting. You can do this with the command-line --exclude option, or by setting exclude in your pyproject.toml file:
📄️ dbt Cloud
As of October 18, 2022, the new dbt Cloud IDE includes a "Format" button that will format your code using sqlfmt. The feature is in Beta, but will be generally available on November 16.
📄️ pre-commit
You can configure pre-commit to run sqlfmt on your repository before you commit changes.
📄️ SQLFluff
You can (and should!) use SQLFluff to lint your SQL queries after they are formatted by sqlfmt. However, the two tools do not see eye-to-eye on formatting (by default), so to avoid lint errors, add the following to your .sqlfluff config file:
📄️ VS Code
You can use the Run on Save extension with sqlfmt to automatically format files when they are saved. After installing the extension: