diff options
| author | Andi Albrecht <albrecht.andi@gmail.com> | 2019-05-25 09:39:50 +0200 |
|---|---|---|
| committer | Andi Albrecht <albrecht.andi@gmail.com> | 2019-05-25 09:39:50 +0200 |
| commit | ab8e2b3b901f69562b11790f966be40f500e3040 (patch) | |
| tree | dd99f2c6773773ce82a279324bea4da47d96f33f | |
| parent | b3475bdd7523a045b0317b24a14d90358d5483bf (diff) | |
| download | sqlparse-ab8e2b3b901f69562b11790f966be40f500e3040.tar.gz | |
Re-use parts of the README in documentation.
| -rw-r--r-- | README.rst | 55 | ||||
| -rw-r--r-- | docs/source/index.rst | 35 | ||||
| -rw-r--r-- | docs/source/license.rst | 4 |
3 files changed, 44 insertions, 50 deletions
@@ -1,53 +1,62 @@ python-sqlparse - Parse SQL statements ====================================== -sqlparse is a non-validating SQL parser module for Python. - |buildstatus|_ |coverage|_ +.. docincludebegin -Install -------- - -Using pip:: - - $ pip install sqlparse +:mod:`sqlparse` is a non-validating SQL parser for Python. +It provides support for parsing, splitting and formatting SQL statements. -From the repository, run:: +The module is compatible with Python 2.7 and Python 3 (>= 3.4) +and released under the terms of the `New BSD license +<https://opensource.org/licenses/BSD-3-Clause>`_. - python setup.py install - -to install sqlparse on your system. - -sqlparse is compatible with Python 2.7 and Python 3 (>= 3.4). +Visit the project page at https://github.com/andialbrecht/sqlparse for +further information about this project. Quick Start ----------- -code-block:: python +.. code-block:: sh + + $ pip install sqlparse + +.. code-block:: python >>> import sqlparse + >>> # Split a string containing two SQL statements: - >>> statements = sqlparse.split('select * from foo; select * from bar;') + >>> 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: - >>> print(sqlparse.format(statements[0], reindent=True, keyword_case='upper')) + >>> first = statemets[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 +Project page + https://github.com/andialbrecht/sqlparse -Documentation - https://sqlparse.readthedocs.io/en/latest/ +Bug tracker + https://github.com/andialbrecht/sqlparse/issues -Issues/Bugs - https://github.com/andialbrecht/sqlparse/issues +Documentation + https://sqlparse.readthedocs.io/ Online Demo https://sqlformat.org/ diff --git a/docs/source/index.rst b/docs/source/index.rst index 3c5956c..cba3314 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,33 +6,9 @@ python-sqlparse =============== -:mod:`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 2.7 and Python 3 (>= 3.4) -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. - - -tl;dr ------ - -.. code-block:: bash - - $ pip install sqlparse - $ python - >>> import sqlparse - >>> print(sqlparse.format('select * from foo', reindent=True)) - select * - from foo - >>> parsed = sqlparse.parse('select * from foo')[0] - >>> parsed.tokens - [<DML 'select' at 0x7f22c5e15368>, <Whitespace ' ' at 0x7f22c5e153b0>, <Wildcard '*' … ] - >>> - +.. include:: ../../README.rst + :start-after: docincludebegin + :end-before: Links Contents -------- @@ -45,6 +21,7 @@ Contents analyzing ui changes + license indices @@ -59,3 +36,7 @@ Bug tracker Documentation https://sqlparse.readthedocs.io/ + +Online Demo + https://sqlformat.org/ + diff --git a/docs/source/license.rst b/docs/source/license.rst new file mode 100644 index 0000000..01f3963 --- /dev/null +++ b/docs/source/license.rst @@ -0,0 +1,4 @@ +License +======= + +.. include:: ../../LICENSE
\ No newline at end of file |
