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

Uploaded Source

Built Distribution

sqlparse-0.4.2-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlparse-0.4.2.tar.gz
  • Upload date:
  • Size: 67.8 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.2.tar.gz
Algorithm Hash digest
SHA256 0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae
MD5 66dce30d92823589f5e5e043f90b4f16
BLAKE2b-256 32fe8a8575debfd924c8160295686a7ea661107fc34d831429cce212b6442edb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlparse-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 42.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d
MD5 7ba95d1ee3802ec2bb6b88d04e06fbfd
BLAKE2b-256 0540d836d55fb3f467243ee839ab7b814822fda522cd395fa41e282684e71ee5

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