Skip to main content

Oxrdflib

PyPI PyPI - Implementation PyPI - Python Version actions status Gitter

Oxrdflib provides an rdflib store based on pyoxigraph. This store is named "Oxigraph".

It also exposes pyoxigraph parsers and serializers as rdflib parser and serializer plugins.

Oxigraph 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 and update evaluation is done by pyoxigraph instead of rdflib if the Oxigraph store is used. SPARQL update evaluation on Graph and ConjunctiveGraph is still done using rdflib because of a limitation in rdflib context management.

Oxrdflib is available on Pypi and installable with:

pip install oxrdflib

The 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.

API

Store

To create a rdflib graph using the Oxigraph store use

rdflib.Graph(store="Oxigraph")

instead of the usual

rdflib.Graph()

Similarly, to get a dataset, use

rdflib.Dataset(store="Oxigraph")

instead of the usual

rdflib.Dataset()

If you want to get the store data persisted on disk, use the open method on the Graph or Dataset object 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 used
graph.open("test_dir")

The store is closed with the close() method or automatically when Python garbage collector collects the store object.

If the open method 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 a pyoxigraph Store object directly 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")))

Parsers and serializers

To use Oxigraph parser, prefix the format identifiers with ox-. For example, to load data using the Oxigraph NTriples parser:

graph.parse(data, format="ox-nt")

and to serialize to Turtle:

graph.serialize(format="ox-ttl")

The following formats are supported:

  • ox-ntriples (ox-nt)
  • ox-nquads (ox-nq)
  • ox-turtle (ox-ttl)
  • ox-trig
  • ox-n3
  • ox-xml
  • ox-json-ld (ox-streaming-json-ld for streaming JSON-LD, note that only JSON-LD 1.0 is supported)

Note that Oxigraph parser and serializers are not 1:1 compatible with the rdflib ones and some minor differences exist.

An optimization has also been setup to skip Python entirely if the Oxigraph parsers and serializers are used with the Oxigraph store.

Differences with rdflib default store

  • relative IRIs are not supported by Oxigraph.
  • Just like the SPARQLStore, Oxigraph joins the initBindings parameter of the query method after the query has been evaluated, instead of injecting them at the beginning of the query.
  • IRI prefixes set using the Graph bind method are not persisted on disk but kept in memory. They should be added again each time the store is opened.

Migration guide

From 0.2 to 0.3

  • The 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 on RocksDB. To migrate you need to first dump your data in RDF using oxrdflib 0.2 and the serialize method, then upgrade to oxrdflib 0.3, and finally reload the data using the parse method.

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.

Metadata

Release files for oxrdflib 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxrdflib 0.5.0
File Size Uploaded
oxrdflib-0.5.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oxrdflib 0.5.0
File Interpreter ABI Platform
oxrdflib-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / oxrdflib-0.5.0.tar.gz

Download URL oxrdflib-0.5.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f83148e2c6d443f7718c6e8936c6b89e36ebb4f1002da69e8f0656e8fb5a0df2
BLAKE2b-256 checksum
How to use checksums
ec97589f244d9a12e033f5216595ef17e7975aabe7f906f709a3a8d1cde37288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2025.

Transparency log

Release files / oxrdflib-0.5.0-py3-none-any.whl

Download URL oxrdflib-0.5.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbe7b57bddca1b2acaf93c71ce3cf2022be8e673052e05ad317682cb9c56b559
BLAKE2b-256 checksum
How to use checksums
c6f79cee8d87f202f88d93179db083508c898deac42b235ff20ade1f456770a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 13, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

1 release file

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page