Skip to main content

A GraphQL server for product DB

Project description

PyPI version Test Status codecov

Acondbs

A GraphQL server for product DB

How to check out and run (for developers)

Prepare environment

Create a virtual environment

python -m venv venv

Enter the virtual environment

source venv/bin/activate

Upgrade pip (optional)

pip install --upgrade pip

Check out

Clone the repository from GitHub

git clone git@github.com:simonsobs/acondbs.git

Install from the clone in the editable mode.

pip install -e acondbs/[tests]

Configure

Create an instance folder of Flask, where the config file and the SQLite DB file are stored. Check out an example instance folder from GitHub

git clone git@github.com:TaiSakuma/acondbs-instance-example.git instance

Set environmental variables

export FLASK_APP="acondbs:create_app('$PWD/instance/config.py')"
export FLASK_ENV=development

Initialize database

flask init-db

An SQLite DB file has been created in the instance folder (instance/product.sqlite3). Tables were defined (The tables were empty. Only fields were defined. No data were inserted in the tables).

Load sample data to DB (optional)

(Optional) Load sample data to the dababase.

flask import-csv acondbs/tests/sample/csv/

Run

Run with the Flask built-in server for the development. (Deployment options for proudction are descriped in the Flask documentation.)

flask run

The above command starts the built-in server that only allows accress from localhost. It starts the server at the default TCP port, usually 5000.

To allow the access from outside, use --host=0.0.0.0 option. The TCP port can be specified by --port option. For example:

flask run --host=0.0.0.0 --port=5000

Access to the server with cURL

Now, you can send GraphQL requests to the server, for example, as follows.

curl -d "query={allMaps { edges { node { name mapper } } }}" localhost:5000/graphql

Access to the server with a web browser

If you access to the server with a web browser, it will show a graphical user interface GraphiQL: http://localhost:5000/graphql

Unit test

Move to the repository

cd acondbs

Run the unit tests

pytest

Run the unit tests with coverage

pytest --cov

Generate the coverage report

coverage html

The report can be found at coverage_html_report/index.html.

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

acondbs-0.3.5.tar.gz (148.4 kB view details)

Uploaded Source

Built Distribution

acondbs-0.3.5-py3-none-any.whl (283.9 kB view details)

Uploaded Python 3

File details

Details for the file acondbs-0.3.5.tar.gz.

File metadata

  • Download URL: acondbs-0.3.5.tar.gz
  • Upload date:
  • Size: 148.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for acondbs-0.3.5.tar.gz
Algorithm Hash digest
SHA256 f15da97a0d8d6b2b6ebddca8ad2350e970cb4d22709943fd29d68b7d3ef5b9c7
MD5 e805d7197acf83782d4089c29d679933
BLAKE2b-256 51b77d7f6c7749e86be24a38e909a41b6353b767cb6171890973301497bb77c3

See more details on using hashes here.

File details

Details for the file acondbs-0.3.5-py3-none-any.whl.

File metadata

  • Download URL: acondbs-0.3.5-py3-none-any.whl
  • Upload date:
  • Size: 283.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for acondbs-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 257a2c31ac0de64dfd0f4bbb70f616f15056a31a9c391b2fe0977c5023e4f4b8
MD5 9e1b74a1cee897bf3e3ecc592bdf8c87
BLAKE2b-256 308565df19a793799033b85f863e86a7f71c82545be074ee65f37fc00ca37c48

See more details on using hashes here.

Supported by

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