skillfed

sqloxide

Python bindings for sqlparser-rs

sqloxide v0.61.1 594.0K downloads/30d#5,847 on PyPI211
Permissive license MIT Active released

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 sqloxide

uv

uv add sqloxide

poetry

poetry add sqloxide

Installing 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

Development Status :: 3 - AlphaLicense :: OSI Approved :: MIT LicenseProgramming Language :: RustTopic :: Database

Tags

sql parser pythonsql ast parsingsql query analysissql syntax treefast sql parsingsql rewritingsql lineage extraction
sql-parsingrust-bindingsast-manipulation

More Database packages