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
msqlparse-0.4.4.tar.gz
(70.1 kB
view details)
File details
Details for the file msqlparse-0.4.4.tar.gz
.
File metadata
- Download URL: msqlparse-0.4.4.tar.gz
- Upload date:
- Size: 70.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97122341eaaa12098fe231a3a901aed5f7ce250d7469849b5001c273dfcc688e |
|
MD5 | 5192cf268430b689d4bdf8d3aa8e02ee |
|
BLAKE2b-256 | d520870da64eb36fd808530084d461c2c821ddbc1d36131295fa39778f3220b5 |