Skip to main content

A non-validating SQL parser.

Project description

buildstatus coverage docs

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

Uploaded Source

Built Distribution

sqlparse-0.4.0-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlparse-0.4.0.tar.gz
  • Upload date:
  • Size: 67.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4

File hashes

Hashes for sqlparse-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d59e473424ae7470778fa4dd0dd7bb666ff324f0a6106c29deb5946ea5367f04
MD5 ebd3655f48192d56aac11847ff18dbe4
BLAKE2b-256 310e67424798bfb5f4216c3c7f49783ddb5fde4f458f08b91d677bb07f7f7a2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlparse-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.4

File hashes

Hashes for sqlparse-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0523026398aea9c8b5f7a4a6d5c0829c285b4fbd960c17b5967a369342e21e01
MD5 65562176d833b5dc6d19a02a6c75a38e
BLAKE2b-256 109636c136013c4a6ecb8c6aa3eed66e6dcea838f85fd80e1446499f1dabfac7

See more details on using hashes here.

Supported by

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