SQLGlot
Pure-Python SQL parser and transpiler that translates queries between 20+ dialects and rewrites, optimizes, and analyzes SQL.
SQLGlot
SQLGlot is a no-dependency Python SQL parser, transpiler, and optimizer. It reads SQL from one dialect and rewrites it into another — translating between DuckDB, Presto/Trino, Spark, Snowflake, BigQuery, Postgres, MySQL, and 20+ others — making it a workhorse for database migrations and cross-engine tooling. Because it builds a real AST, you can also format, optimize, and programmatically analyze queries.
Key features
- Transpile SQL across 20+ dialects with a single call
- Full AST for parsing, rewriting, and query optimization
- Column-level lineage and metadata analysis
- Diff two queries semantically (AST-aware, not text diff)
- Zero runtime dependencies; embeddable in pipelines and agents
Indispensable for teams moving warehouses, building dialect-portable query layers, or giving an LLM agent a deterministic way to validate and rewrite generated SQL.
Curated mirror of the open-source SQLGlot (MIT). Get it from the source.