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.8+ 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.5.0.tar.gz
(83.5 kB
view details)
Built Distribution
sqlparse-0.5.0-py3-none-any.whl
(44.0 kB
view details)
File details
Details for the file sqlparse-0.5.0.tar.gz
.
File metadata
- Download URL: sqlparse-0.5.0.tar.gz
- Upload date:
- Size: 83.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93 |
|
MD5 | cc677bad6c6724a8b0b4aa178cbdacb7 |
|
BLAKE2b-256 | 50265da251cd090ccd580f5cfaa7d36cdd8b2471e49fffce60ed520afc27f4bc |
File details
Details for the file sqlparse-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: sqlparse-0.5.0-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663 |
|
MD5 | f22879a0ed4eb42d721e3c2c57c6a29c |
|
BLAKE2b-256 | 435da0fdd88fd486b39ae1fd1a75ff75b4e29a0df96c0304d462fd407b82efe0 |