A RDFLib SPARQLStore implementation for the VIVO SPARQL query and update APIs.
The VIVO SPARQL APIs require a user email and password for authentication.
See RDFLib's docs for detailed documentation on the SPARQLStore implementation.
pip install vivo-rdflib-sparqlstore
For the latest development version, install directly from Github.
pip install git+https://github.com/lawlesst/rdflib-vivo-sparqlstore.git
See example.py for example usage.
from vstore import VIVOUpdateStore, VIVOStore
from rdflib.namespace import SKOS, RDF
from rdflib.graph import Dataset
#Define the VIVO store
query_endpoint = 'http://localhost:8983/vivo/api/sparqlQuery'
update_endpoint = 'http://localhost:8983/vivo/api/sparqlUpdate'
#Setup the VIVO store
store = VIVOUpdateStore('[email protected]', 'passwd')
store.open((query_endpoint, update_endpoint))
ds = Dataset(store=store)
#All skos:Concepts in the store.
for subj in ds.subjects(predicate=RDF.type, object=SKOS.Concept):
print 'Concept: ', subj
With a default VIVO installation, several URIS for skos:Concepts should be included, e.g.:
Concept: http://vivoweb.org/ontology/core#yearMonthPrecision
Concept: http://vivoweb.org/ontology/core#yearPrecision
Concept: http://vivoweb.org/ontology/core#yearMonthDayTimePrecision
Concept: http://vivoweb.org/ontology/core#yearMonthDayPrecision
A command line tool is included for adding or removing files of triples to/from VIVO. This can be a quick way to insert data into VIVO.
$ vivoUpdate --help
Usage: vivoUpdate [OPTIONS] TRIPLE_FILE ACTION
Pass in the file to add or remove and the action 'add' or 'remove'.
Options:
--email TEXT [required]
--password TEXT [required]
--url TEXT [required]
--named_graph TEXT
--help Show this message and exit.
The email, password, and url options will be read from environment variables if set.
$ export [email protected]
$ export VIVO_PASSWORD=xxxx
$ export VIVO_URL=http://vivo.example.org/