sqlparse
A non-validating SQL parser.
Install
sqlparse on PyPI
pip
pip install sqlparseuv
uv add sqlparsepoetry
poetry add sqlparsePackage facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 237 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: sqlparse-0.5.5-py3-none-any.whl
About sqlparse
from the package's own PyPI description — quoted content, verbatim
python-sqlparse - Parse SQL statements
|buildstatus| |coverage| |docs| |packageversion|
.. docincludebegin
sqlparse is a non-validating SQL parser for Python. It provides support for parsing, splitting and formatting SQL statements.
The module is compatible with Python 3.8+ and released under the terms of the
New BSD license <https://opensource.org/licenses/BSD-3-Clause>_.
Visit the project page at https://github.com/andialbrecht/sqlparse for further information about this project.
Quick Start
.. code-block:: sh
$ pip install sqlparse
.. code-block:: python
>>> import sqlparse
>>> # Split a string containing two SQL statements: >>> raw = 'select * from foo; select * from bar;' >>> statements = sqlparse.split(raw) >>> statements ['select * from foo;', 'select * from bar;']
>>> # Format the first statement and print it out: >>> first = statements[0] >>> print(sqlparse.format(first, reindent=True, keyword_case='upper')) SELECT * FROM foo;
>>> # Parsing a SQL statement: >>> parsed = sqlparse.parse('select * from foo')[0] >>> parsed.tokens [<DML 'select' at...
Read as markdown · JSON record · Source repository · Homepage · Docs
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
sqlparse is a non-validating SQL parser that splits, parses, and formats SQL statements without executing them. It enables developers to programmatically manipulate SQL syntax for analysis, reformatting, and integration into tools.
Excellent install profile: zero runtime dependencies, pure Python wheel distribution, and active maintenance with a recent release (237 days ago). The project maintains 4011 GitHub stars and continues to receive commits.
Released under the permissive BSD license, which allows commercial and private use with minimal restrictions. No notable licensing friction for most use cases.
Usage
pip install sqlparse
import sqlparse
raw = 'select * from foo; select * from bar;'
statements = sqlparse.split(raw)
formatted = sqlparse.format(statements[0], reindent=True, keyword_case='upper')
print(formatted)
Requires Python 3.8 or later.
Verdict: sqlparse is a mature, well-maintained SQL parsing library with zero dependencies, permissive licensing, and no known vulnerabilities. It is suitable for production use in applications requiring SQL analysis, formatting, or tokenization without validation or execution.
Needs verification
- Performance characteristics and parsing speed on large SQL files or complex statements
- Whether the parser handles all SQL dialects equally or has known limitations with vendor-specific SQL syntax
Similar packages
permissive · top 1,000 on PyPI
python-json-loggerpermissive · top 1,000 on PyPI
pg8000permissive · top 1,000 on PyPI
google-cloud-spannerpermissive · top 1,000 on PyPI
prekpermissive · top 1,000 on PyPI
dbt-corepermissive · top 1,000 on PyPI
jupyter-corepermissive · top 1,000 on PyPI
jupyter-clientpermissive · top 1,000 on PyPI
ipython-pygments-lexerspermissive · top 1,000 on PyPI
jupyterlab-pygmentspermissive · top 1,000 on PyPI