Skip to main content

A GraphQL server for product DB

Project description

PyPI version Build 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.2.2.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acondbs-0.2.2-py3-none-any.whl (52.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: acondbs-0.2.2.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.1

File hashes

Hashes for acondbs-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4146a838074f66527db0bb744e440870f2a51cb95ca1624855eca4d72b42ef35
MD5 ddcf91cc4449988959328f04578b48a3
BLAKE2b-256 e0f7f88458ac7cbcc8aa951c3adb83565110a523332a5596f8ee38265439611b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: acondbs-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 52.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.1

File hashes

Hashes for acondbs-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 544b0455f4ccc9d17134e70c2cb960e98d3fd568d3feb9d45830e79fd0d378d2
MD5 227c76a4c35a09775cdf052dbf0afa33
BLAKE2b-256 f5a88d5dc65cd03a8c8d5bbba8a854050d6cc248202bb40d9f815ab5d1adc494

See more details on using hashes here.

Supported by

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