SQLTidy Documentation#

Welcome to SQLTidy! A powerful Python tool for formatting and tidying SQL scripts across multiple database dialects.

Quick Start#

Installation

pip install sqltidy

Command Line

Format SQL files from your terminal:

sqltidy tidy myfile.sql
sqltidy tidy "SQL Files" -r --pattern "*.sql"

See the CLI Reference for complete command reference.

Python API

Use SQLTidy programmatically in your code:

from sqltidy import tidy_sql

sql = "SELECT * FROM users WHERE age > 18"
formatted = tidy_sql(sql)
print(formatted)

See the api for detailed API documentation.

Key Features#

  • Multi-Dialect Support: SQL Server, PostgreSQL, MySQL, Oracle, SQLite

  • Flexible Formatting: Tidy (format) and Rewrite (transform) rules

  • Extensible: Create custom rules and plugins

  • CLI & API: Use from command line or Python code

Indices and tables#