Skip to main content

sqlparse-rs

Rust-accelerated lexer and statement splitter for sqlparse. Output is identical to the original; anything the Rust core does not handle is passed to the original implementation.

import sqlparse, sqlparse_rs
sqlparse_rs.patch()            # sqlparse.split / parse / format now use the Rust lexer
sqlparse.split(script)         # ~50-70x faster
sqlparse_rs.split_many(scripts)  # parallel, GIL released
sqlparse_rs.unpatch()

Speed

sqlparse 0.6.1, Python 3.13, 2 cores, 467 KB of generated queries plus sqlparse's own sample files (bench/bench.py):

operation original Rust speedup
lexer.tokenize (467 KB script) 702 ms 39 ms 18x
split (467 KB script) 1038 ms 15 ms 69x
split each of 1500 queries 1118 ms 22 ms 50x
split_many (6000 queries, parallel) 4240 ms 50 ms 86x
parse x500 1122 ms 848 ms 1.3x
format(reindent) x500 1557 ms 1144 ms 1.4x

parse and format gain less because most of their time is spent in sqlparse's grouping pass and token-object construction, which stay in Python. Porting grouping is the obvious next step.

What is ported

  • The whole SQL_REGEX rule list, as hand-written matchers that reproduce the backtracking order of the original patterns (including quirks such as 12abc lexing as 1 + 2abc).
  • Dollar-quoted literals and multiline comments (find_delimited_spans).
  • Keyword lookup, built from the live Lexer dictionaries.
  • StatementSplitter (BEGIN/END, CASE, IF, LOOP, DECLARE blocks, GO, ...) for split().

Fallbacks (results stay identical)

Bytes input, lone surrogates, customised lexers (set_SQL_REGEX), non-ASCII words that need Python's str.upper(), and non-ASCII text when Python's Unicode database differs from the one the character tables were generated from (tools/gen_tables.py). Keywords added via add_keywords are picked up automatically.

Testing

  • tests/diff_test.py: compares token streams (same token-type objects, same values) and split() with and without strip_semicolon against the original on sample files and fuzzed input; about 2M cases passed against sqlparse 0.6.1.
  • sqlparse's own test suite passes unchanged with sqlparse_rs.patch() applied.
  • tests/test_basic.py: unit tests.

License

BSD 3-Clause, same as sqlparse; see LICENSE.

Metadata

Release files for sqlparse-rs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlparse-rs 0.1.0
File Size Uploaded Provenance Actions
sqlparse_rs-0.1.0.tar.gz 29.6 kB With provenance Details for sqlparse_rs-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sqlparse-rs 0.1.0
File Actions
sqlparse_rs-0.1.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for sqlparse_rs-0.1.0-cp39-abi3-win_amd64.whl
sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
sqlparse_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for sqlparse_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
sqlparse_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for sqlparse_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 1.5 MB

Release files / sqlparse_rs-0.1.0.tar.gz

Download URL sqlparse_rs-0.1.0.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
08dfedb29d255fb2143abce9ce2f90afc33022c93d0e6bc9d054874afc4d17f4
BLAKE2b-256 checksum
How to use checksums
7f75b85f458191a797392a60d8f8623e8772785725d18f113355b07caf86d335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / sqlparse_rs-0.1.0-cp39-abi3-win_amd64.whl

Download URL sqlparse_rs-0.1.0-cp39-abi3-win_amd64.whl
Size 208.4 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
22753db205c0ea804dd6499dfa8bbf931acd82026829c6260fbf91ec38ea1423
BLAKE2b-256 checksum
How to use checksums
0cbbc001592c9f773018efde48a7cf414e88a23ec9a78668524a431ef68f856f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 329.8 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c315c3cee39cd9ed7cbda76d80d4faba5222891702ca3ff78cc39f79273286f7
BLAKE2b-256 checksum
How to use checksums
1f58b583e8f5451af566e3de6a25afa05ce95476b8eb3e0dd75b6ae076327c7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL sqlparse_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 325.0 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
bca741304203c8953c0f64ebd8ede72c38c19939a2b12d43f07a576290070752
BLAKE2b-256 checksum
How to use checksums
9cd5659f783c0db87b8943ba8f568f4650d78ea229c2987d38895caf8de748ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / sqlparse_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL sqlparse_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 292.1 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
74767b4a21617ccc38d10fdf589e1918fff8e5a605c057c42e28fc917762daae
BLAKE2b-256 checksum
How to use checksums
1bfb9818f05fe5293b8d9de6d307371a4b8d0e287238f0ae2ae14de3a071c335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / sqlparse_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL sqlparse_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 301.6 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b28e3fd4385f17372f6718b935445b66c27b81008fe4d7b940b3c095adbf26be
BLAKE2b-256 checksum
How to use checksums
c7436b5850d76af16bb7ed2a2d14403009945e848bb29d85254fc3e3c3380532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for sqlparse-rs 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for sqlparse_rs-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page