A non-validating SQL parser.
Project description
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 '*' … ]
>>>
Links
- Project page
- Bug tracker
- Documentation
- Online Demo
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
Release history Release notifications | RSS feed
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.1.tar.gz
(67.2 kB
view details)
Built Distribution
sqlparse-0.4.1-py3-none-any.whl
(42.2 kB
view details)
File details
Details for the file sqlparse-0.4.1.tar.gz
.
File metadata
- Download URL: sqlparse-0.4.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8 |
|
MD5 | eebbc6b5f1033054873033e54b0c1266 |
|
BLAKE2b-256 | a254da10f9a0235681179144a5ca02147428f955745e9393f859dec8d0d05b41 |
File details
Details for the file sqlparse-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: sqlparse-0.4.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0 |
|
MD5 | 8e8e7586f9dc6c75ed613f823367eb17 |
|
BLAKE2b-256 | 14056e8eb62ca685b10e34051a80d7ea94b7137369d8c0be5c3b9d9b6e3f5dae |