queryparser-python3 0.6.1__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- queryparser_python3-0.7.1/PKG-INFO +180 -0
- queryparser-python3-0.6.1/lib/queryparser_python3.egg-info/PKG-INFO → queryparser_python3-0.7.1/README.md +42 -39
- queryparser_python3-0.7.1/lib/queryparser/__init__.py +1 -0
- queryparser_python3-0.7.1/lib/queryparser/adql/ADQLLexer.py +1465 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/adql/ADQLParser.py +2089 -2186
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/adql/ADQLParserListener.py +38 -56
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/adql/ADQLParserVisitor.py +22 -32
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/adql/adqltranslator.py +206 -74
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/common/common.py +1 -36
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/MySQLLexer.py +2 -2
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/MySQLParser.py +201 -212
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/MySQLParserListener.py +2 -2
- queryparser_python3-0.7.1/lib/queryparser/postgresql/PostgreSQLLexer.py +1192 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/postgresql/PostgreSQLParser.py +2155 -1522
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/postgresql/PostgreSQLParserListener.py +83 -2
- queryparser_python3-0.7.1/lib/queryparser/postgresql/postgresqllisteners.py +3 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/postgresql/postgresqlprocessor.py +1 -4
- queryparser_python3-0.7.1/lib/queryparser_python3.egg-info/PKG-INFO +180 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser_python3.egg-info/SOURCES.txt +1 -1
- queryparser_python3-0.7.1/lib/queryparser_python3.egg-info/requires.txt +5 -0
- queryparser_python3-0.7.1/pyproject.toml +57 -0
- queryparser-python3-0.6.1/PKG-INFO +0 -149
- queryparser-python3-0.6.1/README.md +0 -136
- queryparser-python3-0.6.1/lib/queryparser/__init__.py +0 -9
- queryparser-python3-0.6.1/lib/queryparser/adql/ADQLLexer.py +0 -1497
- queryparser-python3-0.6.1/lib/queryparser/postgresql/PostgreSQLLexer.py +0 -1104
- queryparser-python3-0.6.1/lib/queryparser/postgresql/postgresqllisteners.py +0 -51
- queryparser-python3-0.6.1/lib/queryparser_python3.egg-info/requires.txt +0 -3
- queryparser-python3-0.6.1/setup.py +0 -46
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/LICENSE +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/adql/__init__.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/common/__init__.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/exceptions/__init__.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/__init__.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/mysqllisteners.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/mysql/mysqlprocessor.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser/postgresql/__init__.py +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser_python3.egg-info/dependency_links.txt +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/lib/queryparser_python3.egg-info/top_level.txt +0 -0
- {queryparser-python3-0.6.1 → queryparser_python3-0.7.1}/setup.cfg +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: queryparser-python3
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: Package for parsing PostgreSQL/MySQL and translating ADQL to PostgreSQL/MySQL.
|
|
5
|
+
Author-email: Gal Matijevic <gmatijevic@aip.de>
|
|
6
|
+
Maintainer-email: Kirill Makan <kmakan@aip.de>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Repository, https://github.com/aipescience/queryparser.git
|
|
9
|
+
Project-URL: Issues, https://github.com/aipescience/queryparser/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/aipescience/queryparser/blob/master/CHANGELOG.md
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: antlr4-python3-runtime==4.13.1
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: pytest~=8.2.0; extra == "test"
|
|
26
|
+
Requires-Dist: PyYAML~=6.0; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
queryparser
|
|
30
|
+
===========
|
|
31
|
+
|
|
32
|
+
**Tool for parsing and processing of (MySQL\*)/PostgreSQL and translation of
|
|
33
|
+
ADQL SELECT-like queries**
|
|
34
|
+
|
|
35
|
+
Designed to be used in conjunction with [django-daiquri](https://github.com/django-daiquiri/daiquiri)
|
|
36
|
+
as a query processing backend but it can be easily used as a stand-alone tool
|
|
37
|
+
or integrated into another project.
|
|
38
|
+
|
|
39
|
+
**\*NOTE: Since version 0.7.0 MySQL is not supported (maintained) anymore.**
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
[](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml)
|
|
43
|
+
[](https://coveralls.io/github/aipescience/queryparser?branch=master)
|
|
44
|
+
[](https://github.com/aipescience/queryparser/blob/master/LICENSE)
|
|
45
|
+
[](https://pypi.org/project/queryparser-python3/)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Installation
|
|
50
|
+
------------
|
|
51
|
+
|
|
52
|
+
The easiest way to install the package is by using the pip tool:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m pip install queryparser-python3
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Alternatively, you can clone the repository and install it from there.
|
|
59
|
+
However, this step also requires generating the parser which is a slightly
|
|
60
|
+
more elaborate process (see below).
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Generating the parser from the git repository
|
|
64
|
+
---------------------------------------------
|
|
65
|
+
|
|
66
|
+
To generate the parsers you need `python3` , `java` above version
|
|
67
|
+
7, and `antlr4` (`antlr-4.*-complete.jar` has to be installed inside the
|
|
68
|
+
`/usr/local/lib/`, `/usr/local/bin/` or root directory of the project).
|
|
69
|
+
|
|
70
|
+
The current version of `antlr-4.*-complete.jar` can be downloaded via
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
wget http://www.antlr.org/download/antlr-4.13.1-complete.jar
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
After cloning the project run
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
make
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
and a `lib` directory will be created. After that, run
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python -m pip install .
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
to install the generated parser in your virtual environment.
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
Additional requirements
|
|
92
|
+
-----------------------
|
|
93
|
+
The queryparser assumes that the PostgreSQL database has the extension
|
|
94
|
+
[pg_sphere](https://github.com/kimakan/pgsphere/tree/aiprdbms16) installed.
|
|
95
|
+
Although the `pg_sphere` is not required for the python module, the PostgreSQL
|
|
96
|
+
**queries will not run** without this extension installed on the database.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
Parsing MySQL and PostgreSQL
|
|
100
|
+
----------------------------
|
|
101
|
+
|
|
102
|
+
**Since version 0.7, MySQL part of the parser is not maintained anymore.
|
|
103
|
+
Thus, the MySQL related functionality cannot be guaranteed!**
|
|
104
|
+
|
|
105
|
+
Parsing and processing of MySQL queries can be done by creating an instance
|
|
106
|
+
of the `MySQLQueryProcessor` class
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from queryparser.mysql import MySQLQueryProcessor
|
|
110
|
+
qp = MySQLQueryProcessor()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
feeding it a MySQL query
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
sql = "SELECT a FROM db.tab;"
|
|
117
|
+
qp.set_query(sql)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
and running it with
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
qp.process_query()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
After the processing is completed, the processor object `qp` will include
|
|
127
|
+
tables, columns, functions, and keywords used in the query or will raise a
|
|
128
|
+
`QuerySyntaxError` if there are any syntax errors in the query.
|
|
129
|
+
|
|
130
|
+
Alternatively, passing the query at initialization automatically processes it.
|
|
131
|
+
|
|
132
|
+
PostgreSQL parsing is very similar to MySQL, except it requires importing
|
|
133
|
+
the `PostgreSQLProcessor` class:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from queryparser.postgresql import PostgreSQLQueryProcessor
|
|
137
|
+
qp = PostgreSQLQueryProcessor()
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The rest of the functionality remains the same.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
Translating ADQL
|
|
144
|
+
----------------
|
|
145
|
+
|
|
146
|
+
Translation of ADQL queries is done similarly by first creating an instance of
|
|
147
|
+
the `ADQLQueryTranslator` class
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from queryparser.adql import ADQLQueryTranslator
|
|
151
|
+
adql = "SELECT TOP 100 POINT('ICRS', ra, de) FROM db.tab;"
|
|
152
|
+
adt = ADQLQueryTranslator(adql)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
and calling
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
adt.to_postgresql()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
which returns a translated string representing a valid MySQL query if
|
|
162
|
+
the ADQL query had no errors. The PostgreSQL query can then be parsed with the
|
|
163
|
+
`PostgreSQLQueryProcessor` in the same way as shown above.
|
|
164
|
+
|
|
165
|
+
Testing
|
|
166
|
+
-------
|
|
167
|
+
|
|
168
|
+
First in the root directory of the project, install optional dependencies
|
|
169
|
+
(`PyYAML` and `pytest`) by running
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
python -m pip install .[test]
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
then run the test suite with
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python -m pytest lib/
|
|
179
|
+
```
|
|
180
|
+
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: queryparser-python3
|
|
3
|
-
Version: 0.6.1
|
|
4
|
-
Summary: Parses PostgreSQL/MySQL and translates ADQL to PostgreSQL/MySQL.
|
|
5
|
-
Home-page: https://github.com/aipescience/queryparser
|
|
6
|
-
Author: Gal Matijevic
|
|
7
|
-
Author-email: gmatijevic@aip.de
|
|
8
|
-
Maintainer: Gal Matijevic
|
|
9
|
-
Maintainer-email: gmatijevic@aip.de
|
|
10
|
-
License: Apache-2.0
|
|
11
|
-
Description-Content-Type: text/markdown
|
|
12
|
-
License-File: LICENSE
|
|
13
|
-
|
|
14
1
|
queryparser
|
|
15
2
|
===========
|
|
16
3
|
|
|
17
|
-
**Tool for parsing and processing of MySQL/PostgreSQL and translation of
|
|
4
|
+
**Tool for parsing and processing of (MySQL\*)/PostgreSQL and translation of
|
|
18
5
|
ADQL SELECT-like queries**
|
|
19
6
|
|
|
20
7
|
Designed to be used in conjunction with [django-daiquri](https://github.com/django-daiquiri/daiquiri)
|
|
21
8
|
as a query processing backend but it can be easily used as a stand-alone tool
|
|
22
9
|
or integrated into another project.
|
|
23
10
|
|
|
11
|
+
**\*NOTE: Since version 0.7.0 MySQL is not supported (maintained) anymore.**
|
|
12
|
+
|
|
24
13
|
|
|
25
14
|
[](https://github.com/aipescience/queryparser/actions/workflows/pytest.yml)
|
|
26
15
|
[](https://coveralls.io/github/aipescience/queryparser?branch=master)
|
|
@@ -35,9 +24,7 @@ Installation
|
|
|
35
24
|
The easiest way to install the package is by using the pip tool:
|
|
36
25
|
|
|
37
26
|
```bash
|
|
38
|
-
|
|
39
|
-
pip install queryparser-python3
|
|
40
|
-
|
|
27
|
+
python -m pip install queryparser-python3
|
|
41
28
|
```
|
|
42
29
|
|
|
43
30
|
Alternatively, you can clone the repository and install it from there.
|
|
@@ -50,45 +37,62 @@ Generating the parser from the git repository
|
|
|
50
37
|
|
|
51
38
|
To generate the parsers you need `python3` , `java` above version
|
|
52
39
|
7, and `antlr4` (`antlr-4.*-complete.jar` has to be installed inside the
|
|
53
|
-
`/usr/local/lib
|
|
40
|
+
`/usr/local/lib/`, `/usr/local/bin/` or root directory of the project).
|
|
41
|
+
|
|
42
|
+
The current version of `antlr-4.*-complete.jar` can be downloaded via
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
wget http://www.antlr.org/download/antlr-4.13.1-complete.jar
|
|
46
|
+
```
|
|
54
47
|
|
|
55
48
|
After cloning the project run
|
|
56
49
|
|
|
57
50
|
```bash
|
|
58
|
-
|
|
51
|
+
make
|
|
59
52
|
```
|
|
60
53
|
|
|
61
54
|
and a `lib` directory will be created. After that, run
|
|
62
55
|
|
|
63
56
|
```bash
|
|
64
|
-
|
|
57
|
+
python -m pip install .
|
|
65
58
|
```
|
|
66
59
|
|
|
67
60
|
to install the generated parser in your virtual environment.
|
|
68
61
|
|
|
69
62
|
|
|
63
|
+
Additional requirements
|
|
64
|
+
-----------------------
|
|
65
|
+
The queryparser assumes that the PostgreSQL database has the extension
|
|
66
|
+
[pg_sphere](https://github.com/kimakan/pgsphere/tree/aiprdbms16) installed.
|
|
67
|
+
Although the `pg_sphere` is not required for the python module, the PostgreSQL
|
|
68
|
+
**queries will not run** without this extension installed on the database.
|
|
69
|
+
|
|
70
|
+
|
|
70
71
|
Parsing MySQL and PostgreSQL
|
|
71
72
|
----------------------------
|
|
72
73
|
|
|
74
|
+
**Since version 0.7, MySQL part of the parser is not maintained anymore.
|
|
75
|
+
Thus, the MySQL related functionality cannot be guaranteed!**
|
|
76
|
+
|
|
73
77
|
Parsing and processing of MySQL queries can be done by creating an instance
|
|
74
78
|
of the `MySQLQueryProcessor` class
|
|
75
79
|
|
|
76
80
|
```python
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
from queryparser.mysql import MySQLQueryProcessor
|
|
82
|
+
qp = MySQLQueryProcessor()
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
feeding it a MySQL query
|
|
82
86
|
|
|
83
87
|
```python
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
sql = "SELECT a FROM db.tab;"
|
|
89
|
+
qp.set_query(sql)
|
|
86
90
|
```
|
|
87
91
|
|
|
88
92
|
and running it with
|
|
89
93
|
|
|
90
94
|
```python
|
|
91
|
-
|
|
95
|
+
qp.process_query()
|
|
92
96
|
```
|
|
93
97
|
|
|
94
98
|
After the processing is completed, the processor object `qp` will include
|
|
@@ -101,8 +105,8 @@ PostgreSQL parsing is very similar to MySQL, except it requires importing
|
|
|
101
105
|
the `PostgreSQLProcessor` class:
|
|
102
106
|
|
|
103
107
|
```python
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
from queryparser.postgresql import PostgreSQLQueryProcessor
|
|
109
|
+
qp = PostgreSQLQueryProcessor()
|
|
106
110
|
```
|
|
107
111
|
|
|
108
112
|
The rest of the functionality remains the same.
|
|
@@ -115,35 +119,34 @@ Translation of ADQL queries is done similarly by first creating an instance of
|
|
|
115
119
|
the `ADQLQueryTranslator` class
|
|
116
120
|
|
|
117
121
|
```python
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
from queryparser.adql import ADQLQueryTranslator
|
|
123
|
+
adql = "SELECT TOP 100 POINT('ICRS', ra, de) FROM db.tab;"
|
|
124
|
+
adt = ADQLQueryTranslator(adql)
|
|
121
125
|
```
|
|
122
126
|
|
|
123
127
|
and calling
|
|
124
128
|
|
|
125
129
|
```python
|
|
126
|
-
|
|
130
|
+
adt.to_postgresql()
|
|
127
131
|
```
|
|
128
132
|
|
|
129
133
|
which returns a translated string representing a valid MySQL query if
|
|
130
|
-
the ADQL query had no errors. The
|
|
131
|
-
`
|
|
132
|
-
|
|
134
|
+
the ADQL query had no errors. The PostgreSQL query can then be parsed with the
|
|
135
|
+
`PostgreSQLQueryProcessor` in the same way as shown above.
|
|
133
136
|
|
|
134
137
|
Testing
|
|
135
138
|
-------
|
|
136
139
|
|
|
137
|
-
First, install
|
|
140
|
+
First in the root directory of the project, install optional dependencies
|
|
141
|
+
(`PyYAML` and `pytest`) by running
|
|
138
142
|
|
|
139
143
|
```bash
|
|
140
|
-
|
|
144
|
+
python -m pip install .[test]
|
|
141
145
|
```
|
|
142
146
|
|
|
143
|
-
then run the test suite
|
|
147
|
+
then run the test suite with
|
|
144
148
|
|
|
145
149
|
```bash
|
|
146
|
-
|
|
150
|
+
python -m pytest lib/
|
|
147
151
|
```
|
|
148
152
|
|
|
149
|
-
More elaborate testing procedures can be found in the development notes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.7.1'
|