A Fast Backend API for database queries
Project description
Fast Query Store :zap:
Running locally
You need python
, git
, docker
and docker-compose
to run this project.
Setup
git clone <repository-url>
cd fast-query-store
cp env.example .env
source .env
Install dependencies
python -m venv env
source env/bin/activate
pip install -r requirements.txt
Export config variables
fast-query-store will look for a .json
file containing the queries information. The environment variable queries_file_path
tells where this file is located.
export queries_file_path=/path/to/queries.json
Example of queries.json file
{
"slug-1": {
"query": "SELECT * FROM table_1",
"db_url": "postgresql:///..."
},
"slug-2": {
"query": "SELECT COUNT(1) FROM table_1",
"db_url": "sqlite:///..."
},
"slug-3": {
"query": "SELECT * FROM table_3",
"db_url": "${DATABASE_URL}"
}
}
Note: It is also possible to set the db_url
with a enviroment variable.
Running it
export queries_file_path=queries.json
uvicorn app.main:app --workers 2 --host 0.0.0.0 --port 8000
Getting available query slugs
GET http://localhost:8000/
HTTP/1.1 200 OK
content-length: 73
content-type: application/json
date: Fri, 14 May 2021 12:47:37 GMT
server: uvicorn
{
"slugs": [
"slug-1",
"slug-2",
"slug-3"
]
}
Executing a query
GET http://localhost:8000/query/slug-1
HTTP/1.1 200 OK
content-length: 151
content-type: application/json
date: Fri, 14 May 2021 12:53:09 GMT
server: uvicorn
{
"result_set": [
{
"name": "Cheese",
"price": 9.99,
"product_no": 1
},
{
"name": "Bread",
"price": 1.99,
"product_no": 2
},
{
"name": "Milk",
"price": 2.99,
"product_no": 3
}
]
}
Running the tests
pip install -r requirements-development.txt
source .env
docker-compose f docker-compose.yml up -d
pytest -v
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fast-query-store-0.0.7.dev0.tar.gz
.
File metadata
- Download URL: fast-query-store-0.0.7.dev0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4853794c48a82f3fbc85e69fbaf1d3871942ce82374a5db0453b3cd80a121069 |
|
MD5 | 64dd2e0f7be7f5657479e03ad594b0cc |
|
BLAKE2b-256 | da6476d0b4a00bc82529cea8a158dacf64d2028b2db4949c44be029cf7372d08 |