Skip to main content

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.


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 --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": [

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast-query-store-0.0.7.dev0.tar.gz (4.3 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page