A no-dependency Python SQL parser, transpiler, optimizer, and engine that translates between 31+ SQL dialects.
SQLGlot is a Python SQL parser, transpiler, optimizer, and engine that allows developers to work with SQL across different database dialects. It reads SQL inputs, builds an abstract syntax tree, and outputs correct SQL for target systems like DuckDB, Presto, Spark, and Snowflake, solving the problem of dialect incompatibility and enabling SQL analysis and transformation.
Data engineers, database developers, and tool builders who need to translate, analyze, or optimize SQL across multiple database systems or build SQL-centric applications in Python.
Developers choose SQLGlot for its comprehensive dialect support, pure Python implementation with optional C extensions for performance, and its extensible architecture that allows deep customization and programmatic SQL manipulation.
Python SQL Parser and Transpiler
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports 31+ SQL dialects including major systems like Spark, Snowflake, and BigQuery, with both official and community-maintained options, enabling extensive cross-database compatibility.
Offers optional mypyc-compiled C extensions that significantly speed up parsing, as benchmarks show it can be up to 4-5 times faster than the pure Python version for some queries.
Provides a comprehensive abstract syntax tree (AST) for traversing, modifying, and building SQL queries programmatically, with examples like transforming columns and optimizing joins in the README.
Includes schema-aware query optimization techniques to rewrite queries into a canonical form, though it requires additional schema information and is not enabled by default due to overhead.
The optimizer adds significant overhead and complexity, requiring schema details and not being used by default, which can complicate setup for automatic query rewriting.
As admitted in the README, transpilation is a hard problem with an 'incremental' approach, so some dialect pairs may lack support for certain inputs, relying on community contributions.
Deep customization and AST manipulation require understanding the expression tree structure, which has a learning curve highlighted in the primer and may deter casual users.