shoedog (WIP)
A flexible, efficient plug-and-play query engine built on top of SQLAlchemy, inspired by GraphQL This library is a work in progress!
Setting up
from shoedog import shoedoggify
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
shoedoggify(app, db)
The above code will set up a /shoedog endpoint on your application that takes a POST request. The payload on the POST request is a shoedog payload, with the following syntax:
query Company {
name
year_founded [(* > 1994 and * < 2017) or * == 2019]
investors {
name [any in ['gv', a16z']]
amount_invested [all > 2000000]
}
contact_details (SingaporeContact) {
address
singapore_contact_number
}
}
The above query will return a json response containing all instances of Company where:
- The year founded is between 1994 and 2017, or is exactly 2019
- The investors have all invested over 2,000,000 dollars
- The investors include at least one investor with a name that is either 'gv' or 'a16z'
Furthermore, the json response has a predictable structure, returning only the fields that were requested.
{'companies': [{
'name': 'XYZ Company',
'year_founded': 1995,
'investors': [{
'name': 'gv',
'amount_invested': 2000001
}],
'contact_details': {
'address': '123 Foobar Road',
'singapore_contact_number': '+65 9635 9999'
}
}, ...]}
Notice that
- The
contact_detailswas returned as a dictionary, since it is a different model. - The
contact_detailsfield was cast as aSingaporeContact, which allows us to query for thesingapore_contact_numberfield which is only on that particular subclass. This query would have failed without the cast!
Metadata
Release files for shoedog 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shoedog-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
| shoedog-0.0.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 40.7 kB
Release files / shoedog-0.0.1-py3-none-any.whl
| Download URL | shoedog-0.0.1-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19fc02b1900aee6c2b8980fc996897eb0b2c006c8d74012957b8bad204fb511d
|
|
BLAKE2b-256 checksum How to use checksums |
641efa94879ecc0c4085821ffea7dc20dae285dff93af140d9c47d8ecc967352
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
|
Release files / shoedog-0.0.1-py2-none-any.whl
| Download URL | shoedog-0.0.1-py2-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
92188418d14072db366ceaf4e850ec6ffd660b3365b6b5233738a3774a6b1899
|
|
BLAKE2b-256 checksum How to use checksums |
882a4721e818ef1fa9b68293048f913acc40ba6c0fbe2feb5bd8bbcc78328197
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3
|