SQLTidy Documentation#
Welcome to SQLTidy! A powerful Python tool for formatting and tidying SQL scripts across multiple database dialects.
Contents:
- Getting Started
- CLI Reference
sqltidy tidy- Format SQL Filessqltidy rewrite- Transform SQL Structuresqltidy rulebooks- Manage Configurationsqltidy rules- Manage Custom Rulessqltidy dialects- Explore SQL Dialects- Installation
- Quick Start
- Command Overview
- Common Options
- Common Workflows
- Default Behavior
- File Locations
- API Entry Point
- See Also
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