SQRUFF is an innovative SQL linter and formatter for modern development environments, written in Rust. Key features include:
- Linting: Advanced, customizable SQL linting capabilities to ensure query quality.
- Formatting: Automated, configurable formatting for SQL code consistency.
- Portability: Designed to be easily integrated into various development workflows.
Sqruff currently supports the following SQL dialects:
- ANSI SQL - Standard SQL syntax
- BigQuery
- Clickhouse
- PostgreSQL
- Snowflake
- SparkSql
- SQLite
- DuckDB
While those above are the supported dialects, we are working on adding support for more dialects in the future.
Open our Quary template template, install the recommended sqruff extension, change the file and see the fixes on save.
You can use brew to install sqruff easily on macOS.
brew install quarylabs/quary/sqruff
Using bash
:
curl -fsSL https://raw.githubusercontent.com/quarylabs/sqruff/main/install.sh | bash
Either download the binary from the releases page or compile it yourself and with cargo with the following commands.
rustup toolchain install nightly
cargo +nightly install sqruff
sqruff --help
In addition to the CLI installation mechanism listed above, sqruff is also released as a Visual Studio Code extension.
To lint a SQL file or set of files, run the following command:
sqruff lint <file>
sqruff lint <file1> <file2> <file3>
sqruff lint <directory>
To fix a single or set of files, run the following command:
sqruff fix <file/paths/directory>
To get help on the available commands and options, run the following command:
sqruff --help
For all the details on the CLI commands and options, see the CLI documentation.
For all the details on the rules options, see the configuration documentation.
Join the Quary community on Slack to ask questions, suggest features, or share your projects. Also feel free to raise any issues in the repository.
Contributions are welcome! See CONTRIBUTING.md for guidelines on how to run things locally and on how to contribute.
The sqruff project wouldn't be possible without "heavy inspiration" from Sqlfluff! We're very grateful to their awesome work!