rdflib stores based on pyoxigraph
Project description
Oxrdflib
Oxrdflib provides rdflib stores using pyoxigraph.
The stores could be used as drop-in replacements of the rdflib default ones. They support context but not formulas. Transaction support is not implemented yet.
SPARQL query evaluation is done by pyoxigraph instead of rdflib if an oxrdflib store is used.
Two stores are currently provided:
- An in-memory store, named
"OxMemory"
. - A disk-based store based on the Sled key-value store, named
"OxSled"
.
Oxrdflib is available on Pypi and installable with:
pip install oxrdflib
The oxrdflib stores are automatically registered as rdflib store plugins by setuptools.
API
"OxMemory"
, an in-memory store
To create a rdflib graph with pyoxigraph in memory store use
rdflib.Graph(store="OxMemory")
instead of the usual
rdflib.Graph()
Similarly, to get a conjunctive graph, use
rdflib.ConjunctiveGraph(store="OxMemory")
instead of the usual
rdflib.ConjunctiveGraph()
"OxSled"
, a disk-based store
The disk-based store is based on the Sled key-value store. Sled is not stable yet and its storage system might change in the future.
To open Sled based graph in the directory test_dir
use
graph = rdflib.Graph(store="OxSled")
graph.open("test_dir")
The store is closed with the close()
method or automatically when Python garbage collector collects the store object.
It is also possible to not provide a directory name. In this case, a temporary directory will be created and deleted when the store is closed. For example, this code uses a temporary directory:
rdflib.Graph(store="OxSled")
rdflib.ConjunctiveGraph
is also usable with "OxSled"
.
Development
To run the test do first pip install -e
to register the stores in rdflib plugin registry.
Then, cd tests && python -m unittest
should run the tests.
The code is automatically formatted using black. A pre-commit configuration is provided.
Run pip install pre-commit && pre-commit install
to install pre-commit as a git pre-commit hook in your clone.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.