oxrdflib
raw JSON → 0.5.0 verified Sat May 09 auth: no python
rdflib stores based on pyoxigraph. Version 0.5.0 requires Python >=3.8, upgrades pyoxigraph to 0.5, adds JSON-LD support, and improves SPARQL query behavior. Development is active on GitHub.
pip install oxrdflib Common errors
error ModuleNotFoundError: No module named 'oxrdflib' ↓
cause oxrdflib is not installed.
fix
pip install oxrdflib
error ImportError: cannot import name 'OxigraphStore' from 'oxrdflib' ↓
cause Version mismatch; OxigraphStore was added in v0.1.0.
fix
Update oxrdflib to the latest version: pip install --upgrade oxrdflib
error AttributeError: 'OxigraphStore' object has no attribute 'query' ↓
cause Query is performed on the Graph object, not the store directly.
fix
Use graph.query() instead of store.query(). See quickstart example.
Warnings
breaking In v0.3.0, the 'OxSled' and 'OxMemory' stores were removed and replaced by the 'Oxigraph' store. On-disk storage now uses RocksDB; migrate by dumping data with v0.2, upgrade, then reload. ↓
fix Use OxigraphStore() for both in-memory and on-disk. To persist data, specify a path: OxigraphStore(path='/path/to/db').
deprecated The legacy format names 'ox-ttl', 'ox-nt', etc. are still supported but the new format names 'ox-turtle', 'ox-n-triples' are preferred and may become default in future releases. ↓
fix Use 'ox-turtle' instead of 'ox-ttl', 'ox-n-triples' instead of 'ox-nt', etc.
gotcha Namespaces set via bind() are not persisted to disk. They are only available for the current session. ↓
fix Re-bind namespaces after reloading a store, or store prefix mappings separately.
gotcha The store does not fully implement all rdflib store methods; some operations (e.g., context management) may behave differently. Test your code thoroughly. ↓
fix Review oxrdflib's GitHub issues and test your usage; consider using raw pyoxigraph for advanced features.
Imports
- OxigraphStore wrong
from oxrdflib.store import OxigraphStorecorrectfrom oxrdflib import OxigraphStore - Oxigraph wrong
from oxgraph import Oxigraphcorrectfrom oxrdflib import Oxigraph
Quickstart
from rdflib import Graph
from oxrdflib import OxigraphStore
g = Graph(store=OxigraphStore())
g.parse("example.ttl", format="turtle")
print(len(g))
# Query
g.update("INSERT DATA { <http://example.com/s> <http://example.com/p> <http://example.com/o> .}")
results = g.query("SELECT * WHERE {?s ?p ?o}")
for row in results:
print(row)