sqloxide
Python bindings for sqlparser-rs
What it is and what it does
sqloxide is a Python wrapper around the Rust sqlparser-rs library, providing fast SQL parsing without the GIL. It parses SQL into a typed AST matching the sqlparser-rs schema, and exposes APIs to reconstruct SQL from the AST or apply visitor-pattern mutations to expressions and table relations. The package was built to handle data lineage extraction across large codebases, particularly for complex queries with deep nesting, subselects, and table aliases—problems where pure-Python parsers are either slow or inaccurate.
The package includes free-threaded Python support (3.13t, 3.14t), allowing parallel SQL parsing from multiple threads without locks. Benchmarks show it parses queries roughly 12× faster than sqlglot, 50× faster than sqlparse, and 100× faster than moz-sql-parser. It has no runtime dependencies and ships precompiled wheels for common platforms and Python versions.
Use it for:
- Extract table and column dependencies from hundreds of auto-generated SQL files to build data lineage graphs.
- Rewrite SQL queries programmatically by mutating the AST (e.g., renaming tables, uppercasing identifiers).
- Parse and validate SQL syntax in data pipeline tools or ETL frameworks where speed matters.
- Analyze complex nested queries and subselects where Python-native parsers fail or are too slow.
- Parallelize SQL parsing across multiple threads in free-threaded Python without GIL contention.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
sqloxide parses SQL queries into a typed abstract syntax tree (AST) using Rust bindings for sqlparser-rs, and can reconstruct or rewrite SQL from the AST.
Yes. sqloxide is actively maintained, has no runtime dependencies, offers significant speed advantages over pure-Python alternatives, and covers modern Python versions including free-threaded support. The MIT license is permissive. Install it if you need fast, accurate SQL parsing for lineage, rewriting, or analysis; skip it only if you need extensive documentation or are locked to older Python versions.
Install
sqloxide on PyPI
pip
pip install sqloxideuv
uv add sqloxidepoetry
poetry add sqloxideInstalling sqloxide
Before you install
Medium install friction due to compiled wheels, but well-supported across Python 3.9–3.14 on Linux, macOS, and Windows. Active maintenance with recent releases; last commit 2026-04-09.
License in practice
MIT license permits unrestricted use, modification, and distribution in proprietary and open-source projects with minimal restrictions.
Quickstart
pip install sqloxide
from sqloxide import parse_sql
sql = "SELECT col1, col2 FROM table1 WHERE col1 = 1"
ast = parse_sql(sql=sql, dialect='ansi')
print(ast)
Requires Python 3.9 or later; precompiled wheels available for Python 3.9–3.14 on Linux, macOS, and Windows.
Verify before relying
- Whether the AST schema and mutation APIs are stable across minor versions or subject to breaking changes.
- Performance characteristics on very large or deeply nested queries beyond the benchmarks shown.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 130 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 594,012/month — #5,847 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sqloxide-0.61.1-cp310-cp310-macosx_10_12_x86_64.whl; sqloxide-0.61.1-cp310-cp310-macosx_11_0_arm64.whl; sqloxide-0.61.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; sqloxide-0.61.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; sqloxide-0.61.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl; sqloxide-0.61.1-cp310-cp310-win_amd64.whl; sqloxide-0.61.1-cp311-cp311-macosx_10_12_x86_64.whl; sqloxide-0.61.1-cp311-cp311-macosx_11_0_arm64.whl; sqloxide-0.61.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; sqloxide-0.61.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; sqloxide-0.61.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl; sqloxide-0.61.1-cp311-cp311-win_amd64.whl; sqloxide-0.61.1-cp312-cp312-macosx_10_12_x86_64.whl; sqloxide-0.61.1-cp312-cp312-macosx_11_0_arm64.whl; sqloxide-0.61.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; sqloxide-0.61.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; sqloxide-0.61.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl; sqloxide-0.61.1-cp312-cp312-win_amd64.whl; sqloxide-0.61.1-cp313-cp313-macosx_10_12_x86_64.whl; sqloxide-0.61.1-cp313-cp313-macosx_11_0_arm64.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
sqlglotSQLGlot parses, transpiles, optimizes, and…
permissive · top 1,000 on PyPI
fugue-sql-antlrParses Fugue SQL dialect into an abstract…
permissive · top 5,000 on PyPI
collate-sqllineageAnalyzes SQL statements to extract source and…
permissive · top 5,000 on PyPI
sqlglotrsA SQL parser, transpiler, and optimizer that…
permissive · top 5,000 on PyPI
gritqlGritQL is a Python binding for a declarative…
permissive · top 15,000 on PyPI
mo-sql-parsingParses SQL queries into JSON-serializable parse…
copyleft · top 15,000 on PyPI
pglastParses PostgreSQL SQL statements into an…
copyleft · top 5,000 on PyPI
moz-sql-parserParses SQL queries into JSON-serializable parse…
copyleft · top 15,000 on PyPI
ast-serializeParses Python source files and serializes their…
permissive · top 1,000 on PyPI