skillfed

sqlparse

A non-validating SQL parser.

sqlparse Permissive license Active 4,011 v0.5.5 released

Install

sqlparse on PyPI

pip

pip install sqlparse

uv

uv add sqlparse

poetry

poetry add sqlparse

Package 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: DatabaseTopic :: Software Development

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
sql parser pythonparse sql statementsformat sql codesplit sql queriessql syntax analysissql tokenizersql formatter library

Similar packages