A non-validating SQL parser module for Python (LADI project)
Go to file
Andi Albrecht 982ecdf1ef Bump version to 0.4.0. 2020-10-07 08:57:20 +02:00
docs Correct capitalization of PyPy. 2020-09-13 08:47:53 +02:00
examples Update copyright notice. 2020-10-07 08:54:27 +02:00
sqlparse Bump version to 0.4.0. 2020-10-07 08:57:20 +02:00
tests Stabilize formatting of invalid WHERE clauses. 2020-09-30 15:39:54 +02:00
.editorconfig Update editorconfig 2016-12-22 22:32:31 -07:00
.gitignore Add pytest_cache to gitignore. 2018-07-28 09:32:35 +02:00
.travis.yml Add Python 3.9-dev to Travis configuration. 2020-10-07 08:36:09 +02:00
AUTHORS Update changelog and authors. 2020-09-30 07:26:40 +02:00
CHANGELOG Bump version to 0.4.0. 2020-10-07 08:57:20 +02:00
LICENSE Add or Update copyright year to files 2016-06-04 11:08:20 -07:00
MANIFEST.in Update manifest files 2016-12-22 23:10:15 -07:00
Makefile Update Makefile to reflect changes in current twine. 2020-02-29 14:07:43 +01:00
README.rst Add docs badge. 2020-09-13 12:25:23 +02:00
TODO Remove useless items from TODO. 2015-10-26 20:37:06 +01:00
setup.cfg Move setup data to setup.cfg. 2020-10-07 08:32:45 +02:00
setup.py Update copyright notice. 2020-10-07 08:54:27 +02:00
tox.ini Remove unused pytest-travis-fold test dependency 2020-09-13 08:50:16 +02:00

README.rst

python-sqlparse - Parse SQL statements
======================================

|buildstatus|_
|coverage|_
|docs|_

.. docincludebegin

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 <https://opensource.org/licenses/BSD-3-Clause>`_.

Visit the project page at https://github.com/andialbrecht/sqlparse for
further information about this project.


Quick Start
-----------

.. code-block:: sh

   $ pip install sqlparse

.. code-block:: python

   >>> 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
   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/

.. |buildstatus| image:: https://secure.travis-ci.org/andialbrecht/sqlparse.png?branch=master
.. _buildstatus: https://travis-ci.org/#!/andialbrecht/sqlparse
.. |coverage| image:: https://codecov.io/gh/andialbrecht/sqlparse/branch/master/graph/badge.svg
.. _coverage: https://codecov.io/gh/andialbrecht/sqlparse
.. |docs| image:: https://readthedocs.org/projects/sqlparse/badge/?version=latest
.. _docs: https://sqlparse.readthedocs.io/en/latest/?badge=latest