Skip to main content

python-sqlparse - Parse SQL statements

buildstatus coverage docs packageversion

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.5+ and released under the terms of the New BSD license.

Visit the project page at https://github.com/andialbrecht/sqlparse for further information about this project.

Quick Start

$ pip install sqlparse
>>> 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 0x7f22c5e15368>, <Whitespace ' ' at 0x7f22c5e153b0>, <Wildcard '*' … ]
>>>

Metadata

Release files for sqlparse 0.4.4

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 0.4.4
File Size Uploaded Provenance Actions
sqlparse-0.4.4.tar.gz 72.4 kB Without provenance Details for sqlparse-0.4.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlparse 0.4.4
File Interpreter ABI Platform Actions
sqlparse-0.4.4-py3-none-any.whl Python 3 none any Details for sqlparse-0.4.4-py3-none-any.whl

Total release size: 113.6 kB

Release files / sqlparse-0.4.4.tar.gz

Download URL sqlparse-0.4.4.tar.gz
Size 72.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c
BLAKE2b-256 checksum
How to use checksums
651610f170ec641ed852611b6c9441b23d10b5702ab5288371feab3d36de2574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / sqlparse-0.4.4-py3-none-any.whl

Download URL sqlparse-0.4.4-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3
BLAKE2b-256 checksum
How to use checksums
985a66d7c9305baa9f11857f247d4ba761402cea75db6058ff850ed7128957b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Security for sqlparse 0.4.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.4.4 This release

2 release files No 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