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

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.4.3.tar.gz (70.8 kB view details)

Uploaded Source

Built Distribution

sqlparse-0.4.3-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlparse-0.4.3.tar.gz
  • Upload date:
  • Size: 70.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for sqlparse-0.4.3.tar.gz
Algorithm Hash digest
SHA256 69ca804846bb114d2ec380e4360a8a340db83f0ccf3afceeb1404df028f57268
MD5 180fb4e11a3f79b119868d7c102d7816
BLAKE2b-256 bafa5b7662b04b69f3a34b8867877e4dbf2a37b7f2a5c0bbb5a9eed64efd1ad1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlparse-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for sqlparse-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0323c0ec29cd52bceabc1b4d9d579e311f3e4961b98d174201d5622a23b85e34
MD5 7f21dd4bc74215d68702b8de53dd92a3
BLAKE2b-256 97d331dd2c3e48fc2060819f4acb0686248250a0f2326356306b38a42e059144

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