sqlparse (original) (raw)

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 theNew 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 page

https://github.com/andialbrecht/sqlparse

Bug tracker

https://github.com/andialbrecht/sqlparse/issues

Documentation

https://sqlparse.readthedocs.io/

Online Demo

https://sqlformat.org/

sqlparse is licensed under the BSD license.

Parts of the code are based on pygments written by Georg Brandl and others. pygments-Homepage: http://pygments.org/

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

Built Distribution

File details

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

File metadata

File hashes

Hashes for sqlparse-0.5.3.tar.gz | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | 09f67787f56a0b16ecdbde1bfc7f5d9c3371ca683cfeaa8e6ff60b4807ec9272 | | | MD5 | 9764a42264c9a3102526c87260e73d11 | | | BLAKE2b-256 | e540edede8dd6977b0d3da179a342c198ed100dd2aba4be081861ee5911e4da4 | |

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlparse-0.5.3-py3-none-any.whl | Algorithm | Hash digest | | | ----------- | ---------------------------------------------------------------- | | | SHA256 | cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca | | | MD5 | 28a0ac4500fe5b9b0d7c7e593b21e6df | | | BLAKE2b-256 | a95cbfd6bd0bf979426d405cc6e71eceb8701b148b16c21d2dc3c261efc61c7b | |

See more details on using hashes here.