sqlglot
SQLGlot is a Python SQL parser and transpiler that converts SQL queries between 31 different database dialects (DuckDB, Snowflake, BigQuery, Spark, Presto, etc.). It provides zero-dependency parsing, optimization, and formatting capabilities with a comprehensive test suite and pure-Python implementation.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | tobymao/sqlglot |
| Owner | tobymao |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 9.4k |
| Forks | 1.2k |
| Open issues | 4 |
| Latest release | Unknown |
| Last updated | 2026-07-08 |
| Source | https://github.com/tobymao/sqlglot |
What sqlglot is
Pure-Python SQL parser and code generator supporting 31 dialects with optional mypyc C extensions. Provides AST traversal, expression tree manipulation, syntax error detection, dialect-specific function translation, and query optimization. No external dependencies required; optional C compilation for performance.
Get the sqlglot source
Clone the repository and explore it locally.
git clone https://github.com/tobymao/sqlglot.gitcd sqlglot# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Dialect must be explicitly specified for both parsing (read) and output (write); default behavior uses a generic SQLGlot dialect. Omitting dialect is a common source of parse failures.
- Test suite coverage is comprehensive; validate against your specific SQL patterns and dialect combinations before production use.
- Optional C extension (mypyc compilation) available via `pip install sqlglot[c]` for performance; pure Python fallback always available.
- Parser error detection includes unbalanced parentheses and reserved keyword misuse; configure `unsupported_level` (WARN/RAISE/IMMEDIATE) for dialect incompatibility handling.
- No latestRelease field in data; verify version compatibility and changelog on PyPI; last push to main was 2026-07-08.
When to avoid it — and what to weigh
- Runtime SQL execution required — SQLGlot parses and transpiles SQL but does not execute queries. For execution, pair with a database driver or use SQLFrame (standalone library mentioned for PySpark operations).
- Highly proprietary or undocumented SQL dialects — Limited to 31 supported dialects. Custom or vendor-specific extensions may require custom dialect implementation or may not be fully supported.
- Performance-critical real-time parsing at massive scale — Pure Python with optional C extensions provides good performance, but compiled database-native parsers may be faster for extremely high-throughput scenarios.
License & commercial use
MIT License. Permissive OSI-approved license allowing commercial use, modification, and distribution with minimal restrictions. Attribution appreciated but not legally required.
MIT License explicitly permits commercial use in proprietary products without royalties or disclosure requirements. No copyleft obligations. Suitable for internal tools and SaaS products. Review terms if bundling with other GPL or copyleft libraries.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Parser input validation catches syntax errors and structural issues (unbalanced parentheses, invalid keywords). No inherent SQL injection protection; SQLGlot parses and transpiles but does not sanitize or execute. Input validation is limited to syntactic correctness. Use parameterized queries and input sanitization at the application layer. No known security audit or third-party security review mentioned in provided data.
Alternatives to consider
sqlparse (Python)
Simpler Python SQL parser; lower coverage of edge cases and dialects. Choose if lightweight parsing suffices; SQLGlot better for multi-dialect transpilation and AST manipulation.
Presto/Trino SQL parser (Java-based)
Native parser for Presto/Trino; higher accuracy for those dialects but requires JVM and lacks transpilation to other targets. Choose if Presto/Trino is sole target and Python integration acceptable.
Apache Calcite (Java)
Comprehensive SQL parser and optimizer with broad dialect support; heavyweight compared to SQLGlot. Choose for complex optimization or if Java ecosystem already in use.
Build on sqlglot with DEV.co software developers
SQLGlot handles SQL dialect conversion, formatting, and analysis with minimal dependencies. Get started with pip install sqlglot and evaluate against your real SQL workloads.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
sqlglot FAQ
Why does parsing fail for valid SQL?
Can I execute SQL with SQLGlot?
What about PySpark dataframe support?
How do I handle transpilation errors between dialects?
Software development & web development with DEV.co
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If sqlglot is part of your open-source databases roadmap, our team can implement, customize, migrate, and maintain it.
Standardize SQL Across Your Stack
SQLGlot handles SQL dialect conversion, formatting, and analysis with minimal dependencies. Get started with pip install sqlglot and evaluate against your real SQL workloads.