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

Uploaded Source

Built Distribution

sqlparse-0.4.4-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlparse-0.4.4.tar.gz
  • Upload date:
  • Size: 72.4 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.4.tar.gz
Algorithm Hash digest
SHA256 d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c
MD5 67798c7a0dae90f263d20e9ecf62c8cd
BLAKE2b-256 651610f170ec641ed852611b6c9441b23d10b5702ab5288371feab3d36de2574

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlparse-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 41.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3
MD5 1c30ac6faaef1d750454841a54d9d9a9
BLAKE2b-256 985a66d7c9305baa9f11857f247d4ba761402cea75db6058ff850ed7128957b7

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