queryapigate 0.6.1__tar.gz → 0.7.0__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.
- queryapigate-0.7.0/LICENSE +110 -0
- {queryapigate-0.6.1/queryapigate.egg-info → queryapigate-0.7.0}/PKG-INFO +48 -29
- {queryapigate-0.6.1 → queryapigate-0.7.0}/README.md +46 -27
- {queryapigate-0.6.1 → queryapigate-0.7.0}/pyproject.toml +1 -1
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/__init__.py +1 -1
- {queryapigate-0.6.1 → queryapigate-0.7.0/queryapigate.egg-info}/PKG-INFO +48 -29
- queryapigate-0.6.1/LICENSE +0 -21
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/__main__.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/apikeys.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/app.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/bundle.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/cache.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/cli.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/collection_admin.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/config.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/cors.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/definitions.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/engine.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/errors.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/examples.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/formats.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/lib/h2-2.2.224.jar +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/logging_setup.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/metrics.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/openapi.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/params.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/pool.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/postman.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/ratelimit.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/runners.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/schema.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/sqltools.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/store.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate/ui.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate.egg-info/SOURCES.txt +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate.egg-info/dependency_links.txt +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate.egg-info/entry_points.txt +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate.egg-info/requires.txt +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/queryapigate.egg-info/top_level.txt +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/setup.cfg +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_api_keys.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_audit_log.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_cli.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_collection_bundle.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_collection_postman.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_collections.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_connection_encryption.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_cors_and_rate_limit.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_duckdb.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_examples.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_integration.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_jdbc.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_observability.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_params.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_queryapigate.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_release_check.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_response_cache.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_roles.py +0 -0
- {queryapigate-0.6.1 → queryapigate-0.7.0}/tests/test_sql_guard_fuzz.py +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2024-2026 Anantha Raju C
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queryapigate
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Turn SQL into a REST API: run queries against MySQL, PostgreSQL, ClickHouse, SQLite or H2 over HTTP and get JSON, CSV, XML, YAML or XLSX back.
|
|
5
5
|
Author-email: Anantha Raju C <arcswdev@gmail.com>
|
|
6
|
-
License-Expression: MIT
|
|
6
|
+
License-Expression: FSL-1.1-MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/AnanthaRajuC/QueryAPIGate
|
|
8
8
|
Project-URL: Documentation, https://AnanthaRajuC.github.io/QueryAPIGate/
|
|
9
9
|
Project-URL: Repository, https://github.com/AnanthaRajuC/QueryAPIGate
|
|
@@ -64,7 +64,7 @@ Dynamic: license-file
|
|
|
64
64
|
[](https://codecov.io/gh/AnanthaRajuC/QueryAPIGate)
|
|
65
65
|
[](https://pypi.org/project/queryapigate/)
|
|
66
66
|
[](https://pypi.org/project/queryapigate/)
|
|
67
|
-
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
67
|
+
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
68
68
|

|
|
69
69
|
|
|
70
70
|
### Turn SQL queries into secure, governed REST APIs.
|
|
@@ -81,13 +81,13 @@ serialization boilerplate for it.
|
|
|
81
81
|
Write SQL. Configure the query. Apply access controls. Get an API.
|
|
82
82
|
|
|
83
83
|
~~~bash
|
|
84
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
85
|
-
[{"
|
|
84
|
+
$ curl 'http://127.0.0.1:5000/q/example_film_search?text=Harbor&page_size=2'
|
|
85
|
+
[{"film_id":48,"title":"Broken Harbor","category":"Action","rating":"PG-13"},{"film_id":44,"title":"Electric Harbor","category":"Documentary","rating":"G"}]
|
|
86
86
|
|
|
87
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
$ curl 'http://127.0.0.1:5000/q/example_top_films?top_n=2&category=Comedy&format=csv'
|
|
88
|
+
title,category,rating,rentals,rank
|
|
89
|
+
Electric Signal,Comedy,PG,977,1
|
|
90
|
+
Crimson Garden,Comedy,PG-13,631,2
|
|
91
91
|
~~~
|
|
92
92
|
|
|
93
93
|
<p align="center">
|
|
@@ -273,11 +273,11 @@ version rather than overwriting the old one, so a change to the SQL doesn't sile
|
|
|
273
273
|
### Bound query parameters
|
|
274
274
|
|
|
275
275
|
```sql
|
|
276
|
-
SELECT * FROM
|
|
276
|
+
SELECT * FROM film WHERE film_id = :id
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
```http
|
|
280
|
-
GET /q/
|
|
280
|
+
GET /q/film_by_id?id=7
|
|
281
281
|
```
|
|
282
282
|
|
|
283
283
|
Values are sent to the database separately from the SQL text, so they cannot be injected into it. Parameters can
|
|
@@ -416,8 +416,8 @@ and CI on every push. See [Development](#development) below.
|
|
|
416
416
|
without building a service per query:
|
|
417
417
|
|
|
418
418
|
```http
|
|
419
|
-
GET /q/
|
|
420
|
-
GET /q/
|
|
419
|
+
GET /q/film_by_id?id=7
|
|
420
|
+
GET /q/example_top_films?top_n=5&category=Comedy
|
|
421
421
|
```
|
|
422
422
|
|
|
423
423
|
**Reporting APIs.** Turn an existing analytical SQL report into a reusable endpoint that dashboards or scheduled
|
|
@@ -483,17 +483,17 @@ From a clone: `pip install -e ".[dev]"`. Or use Docker - see [below](#docker).
|
|
|
483
483
|
Fastest: `queryapigate examples load && queryapigate serve` installs four worked [example APIs](documentation/EXAMPLES.md)
|
|
484
484
|
(reporting, dashboard, export, partner) you can try, and `queryapigate examples unload` removes them again.
|
|
485
485
|
|
|
486
|
-
Or, from a clone, the repository ships two sample SQLite databases and a couple of saved queries:
|
|
487
|
-
|
|
488
486
|
~~~bash
|
|
489
|
-
|
|
490
|
-
cp db_connections.example.json db_connections.json
|
|
487
|
+
queryapigate examples load
|
|
491
488
|
queryapigate serve # http://127.0.0.1:5000
|
|
492
489
|
~~~
|
|
493
490
|
|
|
491
|
+
The examples come with a small generated `examples` database (films, customers and rentals), so you can also run ad-hoc SQL
|
|
492
|
+
straight away:
|
|
493
|
+
|
|
494
494
|
~~~bash
|
|
495
495
|
curl -X POST 'http://127.0.0.1:5000/execute_sql?page_size=3' -H 'Content-Type: application/json' \
|
|
496
|
-
-d '{"sql": "SELECT
|
|
496
|
+
-d '{"sql": "SELECT film_id, title, rating FROM film WHERE film_id > :min", "params": {"min": 10}, "connection_name": "examples"}'
|
|
497
497
|
~~~
|
|
498
498
|
|
|
499
499
|
Open <http://127.0.0.1:5000/docs> for the interactive API reference, or <http://127.0.0.1:5000/ui> for a small
|
|
@@ -504,24 +504,26 @@ every supported database) and `saved_sql/`. Edit the file, set `"active": true`,
|
|
|
504
504
|
|
|
505
505
|
## Saving a query as an endpoint
|
|
506
506
|
|
|
507
|
+
This uses the `examples` connection that `queryapigate examples load` sets up:
|
|
508
|
+
|
|
507
509
|
~~~bash
|
|
508
510
|
curl -X PATCH http://127.0.0.1:5000/save_sql_to_file -H 'Content-Type: application/json' -d '{
|
|
509
|
-
"filename": "
|
|
510
|
-
"sql_query": "SELECT * FROM
|
|
511
|
-
"query_parameters": {"id": {"type": "int", "min": 1, "max":
|
|
512
|
-
"connection_name": "
|
|
513
|
-
"author": "me", "description": "Look up
|
|
511
|
+
"filename": "film_by_id",
|
|
512
|
+
"sql_query": "SELECT * FROM film WHERE film_id = :id",
|
|
513
|
+
"query_parameters": {"id": {"type": "int", "min": 1, "max": 60, "description": "Film id"}},
|
|
514
|
+
"connection_name": "examples",
|
|
515
|
+
"author": "me", "description": "Look up a film"
|
|
514
516
|
}'
|
|
515
517
|
|
|
516
|
-
curl 'http://127.0.0.1:5000/q/
|
|
517
|
-
curl 'http://127.0.0.1:5000/q/
|
|
518
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=7&format=yaml'
|
|
519
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=0'
|
|
518
520
|
# {"error": "Invalid parameters: id must be at least 1", "errors": {"id": "must be at least 1"}}
|
|
519
521
|
~~~
|
|
520
522
|
|
|
521
523
|
Rules: `type` (`int`, `float`, `str`, `bool`), `default`, `required`, `enum`, `min`/`max`, `min_length`/`max_length`,
|
|
522
524
|
`pattern` and `description` - see [the API reference](documentation/API.md#parameter-rules).
|
|
523
525
|
|
|
524
|
-
Saving again under the same name adds version 2; `DELETE /saved_sql/
|
|
526
|
+
Saving again under the same name adds version 2; `DELETE /saved_sql/film_by_id?version=1` removes one version.
|
|
525
527
|
|
|
526
528
|
Add `"cache_ttl": 60` to cache a response for that many seconds (`X-Cache: HIT`/`MISS`, `ETag`, `Cache-Control`) -
|
|
527
529
|
opt-in, and never used for a query that writes. See
|
|
@@ -715,12 +717,29 @@ observability are all useful areas. Please review [CONTRIBUTING.md](CONTRIBUTING
|
|
|
715
717
|
|
|
716
718
|
## Third-party components
|
|
717
719
|
|
|
718
|
-
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The
|
|
719
|
-
|
|
720
|
+
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The example data is generated
|
|
721
|
+
locally by `queryapigate examples load`; no third-party datasets are included.
|
|
720
722
|
|
|
721
723
|
## License
|
|
722
724
|
|
|
723
|
-
|
|
725
|
+
QueryAPIGate is **source-available**, under the
|
|
726
|
+
[Functional Source License, Version 1.1, MIT Future License](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
727
|
+
(`FSL-1.1-MIT`) © Anantha Raju C. It is not an OSI-approved open source license.
|
|
728
|
+
|
|
729
|
+
In plain terms - the [LICENSE](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE) is the only authoritative text:
|
|
730
|
+
|
|
731
|
+
- **You may** use, copy, modify and redistribute it for any purpose that is not a *Competing Use* - including running it
|
|
732
|
+
inside your own company, non-commercial education and research, and professional services you provide to someone who
|
|
733
|
+
is themselves licensed to use it.
|
|
734
|
+
- **You may not** make it available to others in a commercial product or service that substitutes for QueryAPIGate or
|
|
735
|
+
offers the same or substantially similar functionality (for example, selling it, or hosting it as a paid service).
|
|
736
|
+
- **Each version becomes MIT** on the second anniversary of the date it was released, and can then be used under MIT terms.
|
|
737
|
+
- **Versions up to and including 0.6.1** were released under the MIT license and remain available under it (the
|
|
738
|
+
releases on PyPI: [`queryapigate`](https://pypi.org/project/queryapigate/) 0.5.0-0.6.1 and
|
|
739
|
+
[`sql2api`](https://pypi.org/project/sql2api/) 0.1.0-0.4.0).
|
|
740
|
+
|
|
741
|
+
Need something the license does not cover, such as offering it as part of a hosted service? Get in touch - commercial
|
|
742
|
+
licensing may be available. This is a summary, not legal advice.
|
|
724
743
|
|
|
725
744
|
## Contact
|
|
726
745
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://codecov.io/gh/AnanthaRajuC/QueryAPIGate)
|
|
5
5
|
[](https://pypi.org/project/queryapigate/)
|
|
6
6
|
[](https://pypi.org/project/queryapigate/)
|
|
7
|
-
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
7
|
+
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
8
8
|

|
|
9
9
|
|
|
10
10
|
### Turn SQL queries into secure, governed REST APIs.
|
|
@@ -21,13 +21,13 @@ serialization boilerplate for it.
|
|
|
21
21
|
Write SQL. Configure the query. Apply access controls. Get an API.
|
|
22
22
|
|
|
23
23
|
~~~bash
|
|
24
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
25
|
-
[{"
|
|
24
|
+
$ curl 'http://127.0.0.1:5000/q/example_film_search?text=Harbor&page_size=2'
|
|
25
|
+
[{"film_id":48,"title":"Broken Harbor","category":"Action","rating":"PG-13"},{"film_id":44,"title":"Electric Harbor","category":"Documentary","rating":"G"}]
|
|
26
26
|
|
|
27
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
$ curl 'http://127.0.0.1:5000/q/example_top_films?top_n=2&category=Comedy&format=csv'
|
|
28
|
+
title,category,rating,rentals,rank
|
|
29
|
+
Electric Signal,Comedy,PG,977,1
|
|
30
|
+
Crimson Garden,Comedy,PG-13,631,2
|
|
31
31
|
~~~
|
|
32
32
|
|
|
33
33
|
<p align="center">
|
|
@@ -213,11 +213,11 @@ version rather than overwriting the old one, so a change to the SQL doesn't sile
|
|
|
213
213
|
### Bound query parameters
|
|
214
214
|
|
|
215
215
|
```sql
|
|
216
|
-
SELECT * FROM
|
|
216
|
+
SELECT * FROM film WHERE film_id = :id
|
|
217
217
|
```
|
|
218
218
|
|
|
219
219
|
```http
|
|
220
|
-
GET /q/
|
|
220
|
+
GET /q/film_by_id?id=7
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
Values are sent to the database separately from the SQL text, so they cannot be injected into it. Parameters can
|
|
@@ -356,8 +356,8 @@ and CI on every push. See [Development](#development) below.
|
|
|
356
356
|
without building a service per query:
|
|
357
357
|
|
|
358
358
|
```http
|
|
359
|
-
GET /q/
|
|
360
|
-
GET /q/
|
|
359
|
+
GET /q/film_by_id?id=7
|
|
360
|
+
GET /q/example_top_films?top_n=5&category=Comedy
|
|
361
361
|
```
|
|
362
362
|
|
|
363
363
|
**Reporting APIs.** Turn an existing analytical SQL report into a reusable endpoint that dashboards or scheduled
|
|
@@ -423,17 +423,17 @@ From a clone: `pip install -e ".[dev]"`. Or use Docker - see [below](#docker).
|
|
|
423
423
|
Fastest: `queryapigate examples load && queryapigate serve` installs four worked [example APIs](documentation/EXAMPLES.md)
|
|
424
424
|
(reporting, dashboard, export, partner) you can try, and `queryapigate examples unload` removes them again.
|
|
425
425
|
|
|
426
|
-
Or, from a clone, the repository ships two sample SQLite databases and a couple of saved queries:
|
|
427
|
-
|
|
428
426
|
~~~bash
|
|
429
|
-
|
|
430
|
-
cp db_connections.example.json db_connections.json
|
|
427
|
+
queryapigate examples load
|
|
431
428
|
queryapigate serve # http://127.0.0.1:5000
|
|
432
429
|
~~~
|
|
433
430
|
|
|
431
|
+
The examples come with a small generated `examples` database (films, customers and rentals), so you can also run ad-hoc SQL
|
|
432
|
+
straight away:
|
|
433
|
+
|
|
434
434
|
~~~bash
|
|
435
435
|
curl -X POST 'http://127.0.0.1:5000/execute_sql?page_size=3' -H 'Content-Type: application/json' \
|
|
436
|
-
-d '{"sql": "SELECT
|
|
436
|
+
-d '{"sql": "SELECT film_id, title, rating FROM film WHERE film_id > :min", "params": {"min": 10}, "connection_name": "examples"}'
|
|
437
437
|
~~~
|
|
438
438
|
|
|
439
439
|
Open <http://127.0.0.1:5000/docs> for the interactive API reference, or <http://127.0.0.1:5000/ui> for a small
|
|
@@ -444,24 +444,26 @@ every supported database) and `saved_sql/`. Edit the file, set `"active": true`,
|
|
|
444
444
|
|
|
445
445
|
## Saving a query as an endpoint
|
|
446
446
|
|
|
447
|
+
This uses the `examples` connection that `queryapigate examples load` sets up:
|
|
448
|
+
|
|
447
449
|
~~~bash
|
|
448
450
|
curl -X PATCH http://127.0.0.1:5000/save_sql_to_file -H 'Content-Type: application/json' -d '{
|
|
449
|
-
"filename": "
|
|
450
|
-
"sql_query": "SELECT * FROM
|
|
451
|
-
"query_parameters": {"id": {"type": "int", "min": 1, "max":
|
|
452
|
-
"connection_name": "
|
|
453
|
-
"author": "me", "description": "Look up
|
|
451
|
+
"filename": "film_by_id",
|
|
452
|
+
"sql_query": "SELECT * FROM film WHERE film_id = :id",
|
|
453
|
+
"query_parameters": {"id": {"type": "int", "min": 1, "max": 60, "description": "Film id"}},
|
|
454
|
+
"connection_name": "examples",
|
|
455
|
+
"author": "me", "description": "Look up a film"
|
|
454
456
|
}'
|
|
455
457
|
|
|
456
|
-
curl 'http://127.0.0.1:5000/q/
|
|
457
|
-
curl 'http://127.0.0.1:5000/q/
|
|
458
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=7&format=yaml'
|
|
459
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=0'
|
|
458
460
|
# {"error": "Invalid parameters: id must be at least 1", "errors": {"id": "must be at least 1"}}
|
|
459
461
|
~~~
|
|
460
462
|
|
|
461
463
|
Rules: `type` (`int`, `float`, `str`, `bool`), `default`, `required`, `enum`, `min`/`max`, `min_length`/`max_length`,
|
|
462
464
|
`pattern` and `description` - see [the API reference](documentation/API.md#parameter-rules).
|
|
463
465
|
|
|
464
|
-
Saving again under the same name adds version 2; `DELETE /saved_sql/
|
|
466
|
+
Saving again under the same name adds version 2; `DELETE /saved_sql/film_by_id?version=1` removes one version.
|
|
465
467
|
|
|
466
468
|
Add `"cache_ttl": 60` to cache a response for that many seconds (`X-Cache: HIT`/`MISS`, `ETag`, `Cache-Control`) -
|
|
467
469
|
opt-in, and never used for a query that writes. See
|
|
@@ -655,12 +657,29 @@ observability are all useful areas. Please review [CONTRIBUTING.md](CONTRIBUTING
|
|
|
655
657
|
|
|
656
658
|
## Third-party components
|
|
657
659
|
|
|
658
|
-
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The
|
|
659
|
-
|
|
660
|
+
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The example data is generated
|
|
661
|
+
locally by `queryapigate examples load`; no third-party datasets are included.
|
|
660
662
|
|
|
661
663
|
## License
|
|
662
664
|
|
|
663
|
-
|
|
665
|
+
QueryAPIGate is **source-available**, under the
|
|
666
|
+
[Functional Source License, Version 1.1, MIT Future License](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
667
|
+
(`FSL-1.1-MIT`) © Anantha Raju C. It is not an OSI-approved open source license.
|
|
668
|
+
|
|
669
|
+
In plain terms - the [LICENSE](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE) is the only authoritative text:
|
|
670
|
+
|
|
671
|
+
- **You may** use, copy, modify and redistribute it for any purpose that is not a *Competing Use* - including running it
|
|
672
|
+
inside your own company, non-commercial education and research, and professional services you provide to someone who
|
|
673
|
+
is themselves licensed to use it.
|
|
674
|
+
- **You may not** make it available to others in a commercial product or service that substitutes for QueryAPIGate or
|
|
675
|
+
offers the same or substantially similar functionality (for example, selling it, or hosting it as a paid service).
|
|
676
|
+
- **Each version becomes MIT** on the second anniversary of the date it was released, and can then be used under MIT terms.
|
|
677
|
+
- **Versions up to and including 0.6.1** were released under the MIT license and remain available under it (the
|
|
678
|
+
releases on PyPI: [`queryapigate`](https://pypi.org/project/queryapigate/) 0.5.0-0.6.1 and
|
|
679
|
+
[`sql2api`](https://pypi.org/project/sql2api/) 0.1.0-0.4.0).
|
|
680
|
+
|
|
681
|
+
Need something the license does not cover, such as offering it as part of a hosted service? Get in touch - commercial
|
|
682
|
+
licensing may be available. This is a summary, not legal advice.
|
|
664
683
|
|
|
665
684
|
## Contact
|
|
666
685
|
|
|
@@ -8,7 +8,7 @@ dynamic = ["version"]
|
|
|
8
8
|
description = "Turn SQL into a REST API: run queries against MySQL, PostgreSQL, ClickHouse, SQLite or H2 over HTTP and get JSON, CSV, XML, YAML or XLSX back."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
11
|
-
license = "MIT"
|
|
11
|
+
license = "FSL-1.1-MIT"
|
|
12
12
|
authors = [{ name = "Anantha Raju C", email = "arcswdev@gmail.com" }]
|
|
13
13
|
keywords = ["sql", "api", "rest", "flask", "database", "mysql", "postgresql", "clickhouse", "sqlite", "h2", "jdbc"]
|
|
14
14
|
classifiers = [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: queryapigate
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: Turn SQL into a REST API: run queries against MySQL, PostgreSQL, ClickHouse, SQLite or H2 over HTTP and get JSON, CSV, XML, YAML or XLSX back.
|
|
5
5
|
Author-email: Anantha Raju C <arcswdev@gmail.com>
|
|
6
|
-
License-Expression: MIT
|
|
6
|
+
License-Expression: FSL-1.1-MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/AnanthaRajuC/QueryAPIGate
|
|
8
8
|
Project-URL: Documentation, https://AnanthaRajuC.github.io/QueryAPIGate/
|
|
9
9
|
Project-URL: Repository, https://github.com/AnanthaRajuC/QueryAPIGate
|
|
@@ -64,7 +64,7 @@ Dynamic: license-file
|
|
|
64
64
|
[](https://codecov.io/gh/AnanthaRajuC/QueryAPIGate)
|
|
65
65
|
[](https://pypi.org/project/queryapigate/)
|
|
66
66
|
[](https://pypi.org/project/queryapigate/)
|
|
67
|
-
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
67
|
+
[](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
68
68
|

|
|
69
69
|
|
|
70
70
|
### Turn SQL queries into secure, governed REST APIs.
|
|
@@ -81,13 +81,13 @@ serialization boilerplate for it.
|
|
|
81
81
|
Write SQL. Configure the query. Apply access controls. Get an API.
|
|
82
82
|
|
|
83
83
|
~~~bash
|
|
84
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
85
|
-
[{"
|
|
84
|
+
$ curl 'http://127.0.0.1:5000/q/example_film_search?text=Harbor&page_size=2'
|
|
85
|
+
[{"film_id":48,"title":"Broken Harbor","category":"Action","rating":"PG-13"},{"film_id":44,"title":"Electric Harbor","category":"Documentary","rating":"G"}]
|
|
86
86
|
|
|
87
|
-
$ curl 'http://127.0.0.1:5000/q/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
$ curl 'http://127.0.0.1:5000/q/example_top_films?top_n=2&category=Comedy&format=csv'
|
|
88
|
+
title,category,rating,rentals,rank
|
|
89
|
+
Electric Signal,Comedy,PG,977,1
|
|
90
|
+
Crimson Garden,Comedy,PG-13,631,2
|
|
91
91
|
~~~
|
|
92
92
|
|
|
93
93
|
<p align="center">
|
|
@@ -273,11 +273,11 @@ version rather than overwriting the old one, so a change to the SQL doesn't sile
|
|
|
273
273
|
### Bound query parameters
|
|
274
274
|
|
|
275
275
|
```sql
|
|
276
|
-
SELECT * FROM
|
|
276
|
+
SELECT * FROM film WHERE film_id = :id
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
```http
|
|
280
|
-
GET /q/
|
|
280
|
+
GET /q/film_by_id?id=7
|
|
281
281
|
```
|
|
282
282
|
|
|
283
283
|
Values are sent to the database separately from the SQL text, so they cannot be injected into it. Parameters can
|
|
@@ -416,8 +416,8 @@ and CI on every push. See [Development](#development) below.
|
|
|
416
416
|
without building a service per query:
|
|
417
417
|
|
|
418
418
|
```http
|
|
419
|
-
GET /q/
|
|
420
|
-
GET /q/
|
|
419
|
+
GET /q/film_by_id?id=7
|
|
420
|
+
GET /q/example_top_films?top_n=5&category=Comedy
|
|
421
421
|
```
|
|
422
422
|
|
|
423
423
|
**Reporting APIs.** Turn an existing analytical SQL report into a reusable endpoint that dashboards or scheduled
|
|
@@ -483,17 +483,17 @@ From a clone: `pip install -e ".[dev]"`. Or use Docker - see [below](#docker).
|
|
|
483
483
|
Fastest: `queryapigate examples load && queryapigate serve` installs four worked [example APIs](documentation/EXAMPLES.md)
|
|
484
484
|
(reporting, dashboard, export, partner) you can try, and `queryapigate examples unload` removes them again.
|
|
485
485
|
|
|
486
|
-
Or, from a clone, the repository ships two sample SQLite databases and a couple of saved queries:
|
|
487
|
-
|
|
488
486
|
~~~bash
|
|
489
|
-
|
|
490
|
-
cp db_connections.example.json db_connections.json
|
|
487
|
+
queryapigate examples load
|
|
491
488
|
queryapigate serve # http://127.0.0.1:5000
|
|
492
489
|
~~~
|
|
493
490
|
|
|
491
|
+
The examples come with a small generated `examples` database (films, customers and rentals), so you can also run ad-hoc SQL
|
|
492
|
+
straight away:
|
|
493
|
+
|
|
494
494
|
~~~bash
|
|
495
495
|
curl -X POST 'http://127.0.0.1:5000/execute_sql?page_size=3' -H 'Content-Type: application/json' \
|
|
496
|
-
-d '{"sql": "SELECT
|
|
496
|
+
-d '{"sql": "SELECT film_id, title, rating FROM film WHERE film_id > :min", "params": {"min": 10}, "connection_name": "examples"}'
|
|
497
497
|
~~~
|
|
498
498
|
|
|
499
499
|
Open <http://127.0.0.1:5000/docs> for the interactive API reference, or <http://127.0.0.1:5000/ui> for a small
|
|
@@ -504,24 +504,26 @@ every supported database) and `saved_sql/`. Edit the file, set `"active": true`,
|
|
|
504
504
|
|
|
505
505
|
## Saving a query as an endpoint
|
|
506
506
|
|
|
507
|
+
This uses the `examples` connection that `queryapigate examples load` sets up:
|
|
508
|
+
|
|
507
509
|
~~~bash
|
|
508
510
|
curl -X PATCH http://127.0.0.1:5000/save_sql_to_file -H 'Content-Type: application/json' -d '{
|
|
509
|
-
"filename": "
|
|
510
|
-
"sql_query": "SELECT * FROM
|
|
511
|
-
"query_parameters": {"id": {"type": "int", "min": 1, "max":
|
|
512
|
-
"connection_name": "
|
|
513
|
-
"author": "me", "description": "Look up
|
|
511
|
+
"filename": "film_by_id",
|
|
512
|
+
"sql_query": "SELECT * FROM film WHERE film_id = :id",
|
|
513
|
+
"query_parameters": {"id": {"type": "int", "min": 1, "max": 60, "description": "Film id"}},
|
|
514
|
+
"connection_name": "examples",
|
|
515
|
+
"author": "me", "description": "Look up a film"
|
|
514
516
|
}'
|
|
515
517
|
|
|
516
|
-
curl 'http://127.0.0.1:5000/q/
|
|
517
|
-
curl 'http://127.0.0.1:5000/q/
|
|
518
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=7&format=yaml'
|
|
519
|
+
curl 'http://127.0.0.1:5000/q/film_by_id?id=0'
|
|
518
520
|
# {"error": "Invalid parameters: id must be at least 1", "errors": {"id": "must be at least 1"}}
|
|
519
521
|
~~~
|
|
520
522
|
|
|
521
523
|
Rules: `type` (`int`, `float`, `str`, `bool`), `default`, `required`, `enum`, `min`/`max`, `min_length`/`max_length`,
|
|
522
524
|
`pattern` and `description` - see [the API reference](documentation/API.md#parameter-rules).
|
|
523
525
|
|
|
524
|
-
Saving again under the same name adds version 2; `DELETE /saved_sql/
|
|
526
|
+
Saving again under the same name adds version 2; `DELETE /saved_sql/film_by_id?version=1` removes one version.
|
|
525
527
|
|
|
526
528
|
Add `"cache_ttl": 60` to cache a response for that many seconds (`X-Cache: HIT`/`MISS`, `ETag`, `Cache-Control`) -
|
|
527
529
|
opt-in, and never used for a query that writes. See
|
|
@@ -715,12 +717,29 @@ observability are all useful areas. Please review [CONTRIBUTING.md](CONTRIBUTING
|
|
|
715
717
|
|
|
716
718
|
## Third-party components
|
|
717
719
|
|
|
718
|
-
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The
|
|
719
|
-
|
|
720
|
+
The wheel bundles the [H2 Database](https://h2database.com) JDBC driver (MPL 2.0 / EPL 1.0). The example data is generated
|
|
721
|
+
locally by `queryapigate examples load`; no third-party datasets are included.
|
|
720
722
|
|
|
721
723
|
## License
|
|
722
724
|
|
|
723
|
-
|
|
725
|
+
QueryAPIGate is **source-available**, under the
|
|
726
|
+
[Functional Source License, Version 1.1, MIT Future License](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE)
|
|
727
|
+
(`FSL-1.1-MIT`) © Anantha Raju C. It is not an OSI-approved open source license.
|
|
728
|
+
|
|
729
|
+
In plain terms - the [LICENSE](https://github.com/AnanthaRajuC/QueryAPIGate/blob/main/LICENSE) is the only authoritative text:
|
|
730
|
+
|
|
731
|
+
- **You may** use, copy, modify and redistribute it for any purpose that is not a *Competing Use* - including running it
|
|
732
|
+
inside your own company, non-commercial education and research, and professional services you provide to someone who
|
|
733
|
+
is themselves licensed to use it.
|
|
734
|
+
- **You may not** make it available to others in a commercial product or service that substitutes for QueryAPIGate or
|
|
735
|
+
offers the same or substantially similar functionality (for example, selling it, or hosting it as a paid service).
|
|
736
|
+
- **Each version becomes MIT** on the second anniversary of the date it was released, and can then be used under MIT terms.
|
|
737
|
+
- **Versions up to and including 0.6.1** were released under the MIT license and remain available under it (the
|
|
738
|
+
releases on PyPI: [`queryapigate`](https://pypi.org/project/queryapigate/) 0.5.0-0.6.1 and
|
|
739
|
+
[`sql2api`](https://pypi.org/project/sql2api/) 0.1.0-0.4.0).
|
|
740
|
+
|
|
741
|
+
Need something the license does not cover, such as offering it as part of a hosted service? Get in touch - commercial
|
|
742
|
+
licensing may be available. This is a summary, not legal advice.
|
|
724
743
|
|
|
725
744
|
## Contact
|
|
726
745
|
|
queryapigate-0.6.1/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Anantha Raju C
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|