Skip to main content

A non-validating SQL parser.

Project description

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.8+ 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 '*'  ]
>>>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlparse-0.5.1.tar.gz (84.5 kB view details)

Uploaded Source

Built Distribution

sqlparse-0.5.1-py3-none-any.whl (44.2 kB view details)

Uploaded Python 3

File details

Details for the file sqlparse-0.5.1.tar.gz.

File metadata

  • Download URL: sqlparse-0.5.1.tar.gz
  • Upload date:
  • Size: 84.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for sqlparse-0.5.1.tar.gz
Algorithm Hash digest
SHA256 bb6b4df465655ef332548e24f08e205afc81b9ab86cb1c45657a7ff173a3a00e
MD5 969a64f03d7da1144fc74aad390f9db4
BLAKE2b-256 7382dfa23ec2cbed08a801deab02fe7c904bfb00765256b155941d789a338c68

See more details on using hashes here.

File details

Details for the file sqlparse-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: sqlparse-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 44.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for sqlparse-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 773dcbf9a5ab44a090f3441e2180efe2560220203dc2f8c0b0fa141e18b505e4
MD5 f902026f43bc7f4ebfca936d3b8d2a64
BLAKE2b-256 5da5b2860373aa8de1e626b2bdfdd6df4355f0565b47e51f7d0c54fe70faf8fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page