Skip to content

Commit ab8e2b3

Browse files
committed
Re-use parts of the README in documentation.
1 parent b3475bd commit ab8e2b3

3 files changed

Lines changed: 44 additions & 50 deletions

File tree

README.rst

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,62 @@
11
python-sqlparse - Parse SQL statements
22
======================================
33

4-
sqlparse is a non-validating SQL parser module for Python.
5-
64
|buildstatus|_
75
|coverage|_
86

7+
.. docincludebegin
98
10-
Install
11-
-------
12-
13-
Using pip::
14-
15-
$ pip install sqlparse
9+
:mod:`sqlparse` is a non-validating SQL parser for Python.
10+
It provides support for parsing, splitting and formatting SQL statements.
1611

17-
From the repository, run::
12+
The module is compatible with Python 2.7 and Python 3 (>= 3.4)
13+
and released under the terms of the `New BSD license
14+
<https://opensource.org/licenses/BSD-3-Clause>`_.
1815

19-
python setup.py install
20-
21-
to install sqlparse on your system.
22-
23-
sqlparse is compatible with Python 2.7 and Python 3 (>= 3.4).
16+
Visit the project page at https://github.com/andialbrecht/sqlparse for
17+
further information about this project.
2418

2519

2620
Quick Start
2721
-----------
2822

29-
code-block:: python
23+
.. code-block:: sh
24+
25+
$ pip install sqlparse
26+
27+
.. code-block:: python
3028
3129
>>> import sqlparse
30+
3231
>>> # Split a string containing two SQL statements:
33-
>>> statements = sqlparse.split('select * from foo; select * from bar;')
32+
>>> raw = 'select * from foo; select * from bar;'
33+
>>> statements = sqlparse.split(raw)
34+
>>> statements
35+
['select * from foo;', 'select * from bar;']
36+
3437
>>> # Format the first statement and print it out:
35-
>>> print(sqlparse.format(statements[0], reindent=True, keyword_case='upper'))
38+
>>> first = statemets[0]
39+
>>> print(sqlparse.format(first, reindent=True, keyword_case='upper'))
3640
SELECT *
3741
FROM foo;
42+
43+
>>> # Parsing a SQL statement:
44+
>>> parsed = sqlparse.parse('select * from foo')[0]
45+
>>> parsed.tokens
46+
[<DML 'select' at 0x7f22c5e15368>, <Whitespace ' ' at 0x7f22c5e153b0>, <Wildcard '*' … ]
3847
>>>
3948
4049
Links
4150
-----
4251

43-
Project Page
44-
https://github.com/andialbrecht/sqlparse
52+
Project page
53+
https://github.com/andialbrecht/sqlparse
4554

46-
Documentation
47-
https://sqlparse.readthedocs.io/en/latest/
55+
Bug tracker
56+
https://github.com/andialbrecht/sqlparse/issues
4857

49-
Issues/Bugs
50-
https://github.com/andialbrecht/sqlparse/issues
58+
Documentation
59+
https://sqlparse.readthedocs.io/
5160

5261
Online Demo
5362
https://sqlformat.org/

docs/source/index.rst

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,9 @@
66
python-sqlparse
77
===============
88

9-
:mod:`sqlparse` is a non-validating SQL parser for Python.
10-
It provides support for parsing, splitting and formatting SQL statements.
11-
12-
The module is compatible with Python 2.7 and Python 3 (>= 3.4)
13-
and released under the terms of the `New BSD license
14-
<https://opensource.org/licenses/BSD-3-Clause>`_.
15-
16-
Visit the project page at https://github.com/andialbrecht/sqlparse for
17-
further information about this project.
18-
19-
20-
tl;dr
21-
-----
22-
23-
.. code-block:: bash
24-
25-
$ pip install sqlparse
26-
$ python
27-
>>> import sqlparse
28-
>>> print(sqlparse.format('select * from foo', reindent=True))
29-
select *
30-
from foo
31-
>>> parsed = sqlparse.parse('select * from foo')[0]
32-
>>> parsed.tokens
33-
[<DML 'select' at 0x7f22c5e15368>, <Whitespace ' ' at 0x7f22c5e153b0>, <Wildcard '*' … ]
34-
>>>
35-
9+
.. include:: ../../README.rst
10+
:start-after: docincludebegin
11+
:end-before: Links
3612

3713
Contents
3814
--------
@@ -45,6 +21,7 @@ Contents
4521
analyzing
4622
ui
4723
changes
24+
license
4825
indices
4926

5027

@@ -59,3 +36,7 @@ Bug tracker
5936

6037
Documentation
6138
https://sqlparse.readthedocs.io/
39+
40+
Online Demo
41+
https://sqlformat.org/
42+

docs/source/license.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
License
2+
=======
3+
4+
.. include:: ../../LICENSE

0 commit comments

Comments
 (0)