|
6 | 6 | # This setup script is part of python-sqlparse and is released under |
7 | 7 | # the BSD License: https://opensource.org/licenses/BSD-3-Clause |
8 | 8 |
|
9 | | -import re |
| 9 | +from setuptools import setup |
10 | 10 |
|
11 | | -from setuptools import setup, find_packages |
12 | 11 |
|
13 | | - |
14 | | -def get_version(): |
15 | | - """Parse __init__.py for version number instead of importing the file.""" |
16 | | - VERSIONFILE = 'sqlparse/__init__.py' |
17 | | - VSRE = r'^__version__ = [\'"]([^\'"]*)[\'"]' |
18 | | - with open(VERSIONFILE) as f: |
19 | | - verstrline = f.read() |
20 | | - mo = re.search(VSRE, verstrline, re.M) |
21 | | - if mo: |
22 | | - return mo.group(1) |
23 | | - raise RuntimeError('Unable to find version in {fn}'.format(fn=VERSIONFILE)) |
24 | | - |
25 | | - |
26 | | -LONG_DESCRIPTION = """ |
27 | | -``sqlparse`` is a non-validating SQL parser module. |
28 | | -It provides support for parsing, splitting and formatting SQL statements. |
29 | | -
|
30 | | -Visit the `project page <https://github.com/andialbrecht/sqlparse>`_ for |
31 | | -additional information and documentation. |
32 | | -
|
33 | | -**Example Usage** |
34 | | -
|
35 | | -
|
36 | | -Splitting SQL statements:: |
37 | | -
|
38 | | - >>> import sqlparse |
39 | | - >>> sqlparse.split('select * from foo; select * from bar;') |
40 | | - [u'select * from foo; ', u'select * from bar;'] |
41 | | -
|
42 | | -
|
43 | | -Formatting statements:: |
44 | | -
|
45 | | - >>> sql = 'select * from foo where id in (select id from bar);' |
46 | | - >>> print(sqlparse.format(sql, reindent=True, keyword_case='upper')) |
47 | | - SELECT * |
48 | | - FROM foo |
49 | | - WHERE id IN |
50 | | - (SELECT id |
51 | | - FROM bar); |
52 | | -
|
53 | | -
|
54 | | -Parsing:: |
55 | | -
|
56 | | - >>> sql = 'select * from someschema.mytable where id = 1' |
57 | | - >>> res = sqlparse.parse(sql) |
58 | | - >>> res |
59 | | - (<Statement 'select...' at 0x9ad08ec>,) |
60 | | - >>> stmt = res[0] |
61 | | - >>> str(stmt) # converting it back to unicode |
62 | | - 'select * from someschema.mytable where id = 1' |
63 | | - >>> # This is how the internal representation looks like: |
64 | | - >>> stmt.tokens |
65 | | - (<DML 'select' at 0x9b63c34>, |
66 | | - <Whitespace ' ' at 0x9b63e8c>, |
67 | | - <Operator '*' at 0x9b63e64>, |
68 | | - <Whitespace ' ' at 0x9b63c5c>, |
69 | | - <Keyword 'from' at 0x9b63c84>, |
70 | | - <Whitespace ' ' at 0x9b63cd4>, |
71 | | - <Identifier 'somes...' at 0x9b5c62c>, |
72 | | - <Whitespace ' ' at 0x9b63f04>, |
73 | | - <Where 'where ...' at 0x9b5caac>) |
74 | | -
|
75 | | -""" |
76 | | - |
77 | | -setup( |
78 | | - name='sqlparse', |
79 | | - version=get_version(), |
80 | | - author='Andi Albrecht', |
81 | | - |
82 | | - url='https://github.com/andialbrecht/sqlparse', |
83 | | - description='Non-validating SQL parser', |
84 | | - long_description=LONG_DESCRIPTION, |
85 | | - license='BSD', |
86 | | - python_requires=">=3.5", |
87 | | - classifiers=[ |
88 | | - 'Development Status :: 5 - Production/Stable', |
89 | | - 'Intended Audience :: Developers', |
90 | | - 'License :: OSI Approved :: BSD License', |
91 | | - 'Operating System :: OS Independent', |
92 | | - 'Programming Language :: Python', |
93 | | - 'Programming Language :: Python :: 3', |
94 | | - 'Programming Language :: Python :: 3 :: Only', |
95 | | - 'Programming Language :: Python :: 3.5', |
96 | | - 'Programming Language :: Python :: 3.6', |
97 | | - 'Programming Language :: Python :: 3.7', |
98 | | - 'Programming Language :: Python :: 3.8', |
99 | | - 'Programming Language :: Python :: 3.9', |
100 | | - 'Programming Language :: Python :: Implementation :: CPython', |
101 | | - 'Programming Language :: Python :: Implementation :: PyPy', |
102 | | - 'Topic :: Database', |
103 | | - 'Topic :: Software Development', |
104 | | - ], |
105 | | - packages=find_packages(exclude=('tests',)), |
106 | | - entry_points={ |
107 | | - 'console_scripts': [ |
108 | | - 'sqlformat = sqlparse.__main__:main', |
109 | | - ] |
110 | | - }, |
111 | | -) |
| 12 | +setup() |
0 commit comments