Skip to main content

OBA Sparql Manager

Project description

OBA Sparql Query Manager Build Status codecov

OBA Sparql Query Manager is a Python Module to translate CRUD requests to SPARQL queries. This module is used by OBA project to generate a REST API from OWL ontologies.

OBA sparql use JSON-LD contexts to translate RDF triples to JSON, and vice versa.

Quick Start

Generate the context files

Simply speaking, a context is used to map terms to IRIs. Terms are case sensitive and most valid strings that are not reserved JSON-LD keywords can be used as a term.

To generate the context files, we recommend to use:

  1. OBA
  2. owl2jsonld

TODO: Insert a good example.

from obasparql import QueryManager
from test.settings import dbpedia_queries, dbpedia_context, dbpedia_endpoint, dbpedia_prefix
from obasparql.static import * 
queries = "queries/"
contexts = "contexts/"
dbpedia_endpoint = "https://dbpedia.org/sparql"
dbpedia_prefix = "http://dbpedia.org/resource"
graph = None

query_manager = QueryManager(queries_dir=queries,
                                  context_dir=contexts,
                                  endpoint=dbpedia_endpoint,
                                  named_graph_base=graph,
                                  uri_prefix=dbpedia_prefix)

query_manager.get_one_resource()
query_manager.get_all_resource()

Supported features

OBA sparql supports two types of queries:

  • Default queries: queries related to the CRUD requests.
    • Get a resource and get all the resource by type.
  • Custom queries: In some cases, users need to implement custom queries that are not the default instances of a class of the ontology (e.g., get all instances of a class that comply with certain conditions)

Default queries

Custom queries

Testing

This repository is using pytest for the testing

$ pip install -r test-requirements.txt
$ pytest

For more information. You can inspect the file .travis.yaml

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

obasparql-4.0.7.tar.gz (40.0 kB view details)

Uploaded Source

Built Distribution

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

obasparql-4.0.7-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file obasparql-4.0.7.tar.gz.

File metadata

  • Download URL: obasparql-4.0.7.tar.gz
  • Upload date:
  • Size: 40.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for obasparql-4.0.7.tar.gz
Algorithm Hash digest
SHA256 495c6085e5802f5420032411f807ca9355d548ce0bd56b3b57a6ceff49822e65
MD5 d718b19420f0f27cc7e923227957a35f
BLAKE2b-256 763bdc4f38df39df0d63e79bb89baa1f84271a35d523e5e229c41f1fae672910

See more details on using hashes here.

File details

Details for the file obasparql-4.0.7-py3-none-any.whl.

File metadata

  • Download URL: obasparql-4.0.7-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for obasparql-4.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a28c3dfc8fab121d1fa73e9e5ae8d639367f7aabf3de1daf93e8bef105846392
MD5 483fae739c76ccfb9461ac83afaddfcf
BLAKE2b-256 a0122e24d3f92c22ea1b10cbb6fadf924d79d468cbcb026554332aa3d7024c9a

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