Package: oxrdflib
OxrdflibOxrdflib provides anrdflibstore based onpyoxigraph.
This store is named"Oxigraph".This store can be used as drop-in replacement of the rdflib default one. It support context but not formulas.
Transaction support is not implemented yet.SPARQL query evaluation is done by pyoxigraph instead of rdflib if the Oxigraph store is used.
SPARQL update evaluation is still done using rdflib because ofa limitation in rdflib context management.Oxrdflib isavailable on Pypiand installable with:pipinstalloxrdflibThe oxrdflib store is automatically registered as an rdflib store plugin by setuptools.Warning:Oxigraph is not stable yet and its storage format might change in the future.
To migrate to future version you might have to dump and load the store content.
However, Oxigraph should be in a good enough shape to power most of use cases if you are not afraid of down time and data loss.APITo create a rdflib graph using the Oxigraph store userdflib.Graph(store="Oxigraph")instead of the usualrdflib.Graph()Similarly, to get a conjunctive graph, userdflib.ConjunctiveGraph(store="Oxigraph")instead of the usualrdflib.ConjunctiveGraph()and to get a dataset, userdflib.Dataset(store="Oxigraph")instead of the usualrdflib.Dataset()If you want to get the store data persisted on disk, use theopenmethod on theGraphobject (orConjunctiveGraphorDataset) with the directory where data should be persisted. For example:graph=rdflib.Graph(store="Oxigraph",identifier="http://example.com")# without identifier, some blank node will be usedgraph.open("test_dir")The store is closed with theclose()method or automatically when Python garbage collector collects the store object.If theopenmethod is not called Oxigraph will automatically use a ramdisk on Linux and a temporary file in the other operating systems.To do anything else, use the usual rdflib python API.It is also possible to directly inject apyoxigraphStoreobjectdirectly into an Oxrdflib store:graph=rdflib.Graph(store=oxrdflib.OxigraphStore(store=pyoxigraph.Store("test_dir")))This might be handy to e.g. open the database as read-only:graph=rdflib.Graph(store=oxrdflib.OxigraphStore(store=pyoxigraph.Store.read_only("test_dir")))Differences with rdflib default storerelative IRIs are not supported by Oxigraph.Just like theSPARQLStore, Oxigraph joins theinitBindingsparameter of thequerymethod after the query has been evaluated, instead of injecting them at the beginning of the query.IRI prefixes set using theGraphbindmethod are not persisted on disk but kept in memory. They should be added again each time the store is opened.Migration guideFrom 0.2 to 0.3The 0.2 stores named"OxSled"and"OxMemory"have been merged into the"Oxigraph"store.The on-disk storage system provided by"OxSled"has been dropped and replaced by a new storage system based onRocksDB.
To migrate you need to first dump your data in RDF usingoxrdflib0.2 and theserializemethod, then upgrade tooxrdflib0.3, and finally reload the data using theparsemethod.DevelopmentTo run the test do firstpip install -e .to register the stores in rdflib plugin registry.
Then,cd tests && python -m unittestshould run the tests.The code is automatically formatted usingblack. Apre-commitconfiguration is provided.
Runpip install pre-commit && pre-commit installto install pre-commit as a git pre-commit hook in your clone.