Skip to main content
  1. Posts/

SQLFluff: Auto-Fix Messy SQL with One Command

··240 words·2 mins·

🧹 Does your SQL have style inconsistencies across teams? SQLFluff is the eslint of SQL.

Consistent SQL style matters: it improves readability, speeds up code reviews and makes bugs easier to identify. Manual reviews can catch formatting issues, but they’re time-consuming and inconsistent.

SQLFluff solves this with automated linting and formatting across 30+ SQL dialects (PostgreSQL, MySQL, BigQuery, Snowflake, DuckDB, etc.).

What it does:

🔍 Lint → identifies style violations in your queries 🔧 Fix → automatically corrects most problems with sqlfluff fix 📐 Consistency → applies uniform standards across the entire codebase

Supported templates:

  • Jinja (useful for dynamic templates)
  • SQL placeholders (SQLAlchemy)
  • Python format strings
  • dbt (with plugin — widely used in analytics engineering projects)
sqlfluff lint my_query.sql
sqlfluff fix my_query.sql

You can also integrate it into your CI/CD so PRs with poorly formatted SQL don’t pass.

💡 Explanation in a nutshell
#

SQLFluff does for SQL what Black does for Python: it removes the style debate and resolves it automatically. If you work with dbt, SQL pipelines or have a data engineering team, integrating it into your workflow is a no-brainer.

More information at the link 👇

Also published on LinkedIn.
Juan Pedro Bretti Mandarano
Author
Juan Pedro Bretti Mandarano