Sqruff SQL Linter

0.38.0 · active · verified Thu Apr 16

Sqruff is a high-performance SQL linter and formatter written in Rust, designed for speed and portability. It supports various SQL dialects, including ANSI, BigQuery, and Postgres, with ongoing development for others like Snowflake and Clickhouse. Currently at version 0.38.0, it maintains an active release cadence with frequent updates and is often noted for its significant speed improvement over similar tools.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install Sqruff and use its primary command-line interface to lint and format a SQL file. It involves creating a sample SQL file and a `.sqruff` configuration file to specify the SQL dialect.

# Create a SQL file to lint
echo "SELECT  col1, col2 FROM my_table;" > bad_sql.sql

# Create a configuration file (e.g., .sqruff)
echo "[sqruff]\ndialect = postgres" > .sqruff

# Run the linter
sqruff lint bad_sql.sql

# Or lint all SQL files in the current directory with the config
sqruff lint .

# Run the formatter
sqruff format bad_sql.sql

view raw JSON →