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.
dbt Power User (VS Code Extension)
dbt Power User is a VS Code Extension to make VS Code work seamlessly with dbt.
Docker
You can use Docker to run sqlfmt without installing Python locally.
GitHub Actions
sqlfmt can be easily installed and run in a GitHub Actions Workflow. Alternatively, Trunk provides an Action that can be used to invoke sqlfmt.
pre-commit
You can configure pre-commit to run sqlfmt on your repository before you commit changes.
SQLFluff
You can 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:
Trunk
You can use Trunk to integrate sqlfmt into VSCode, GitHub Actions, and your local development workflow.
VS Code
There are several ways to integrate sqlfmt with VS Code. All require installation of an Extension from the VS Code Marketplace.