An adaptation of RDFLib BerkeleyDB Store’s key-value approach, using LevelDB as a back-end.
Implemented by Gunnar Grimnes, based on an original contribution by Drew Perttula.
Migrated to Python 3 / RDFLib=>6 and adjusted to use the plyvel / plyvel-wheels Python-LevelDB inferface by Graham Higgins.
pip install git+https://github.com/RDFLib/rdflib-leveldb#egg=rdflib_leveldb`
git clone https://github.com/RDFLib/rdflib-leveldb.git
cd rdflib-leveldb
pip install .
# Optionally
pip install -r requirements.dev.txt
./run_tests.py
python setup.py install
git clone https://github.com/RDFLib/rdflib-leveldb.git
cd rdflib-leveldb
python setup.py install
# Optionally
pip install -r requirements.dev.txt
./run_tests.py
from rdflib import plugin, Graph, URIRef
from rdflib.store import Store
import tempfile
import os
def example():
path = os.path.join(tempfile.gettempdir(), "testleveldb")
store = plugin.get("LevelDB", Store)(identifier=URIRef("rdflib_leveldb_test"))
g = Graph(store)
g.open(path, create=True)
# Parse in an RDF file hosted on the Internet
g.parse("http://www.w3.org/People/Berners-Lee/card")
# Loop through each triple in the graph (subj, pred, obj)
for subj, pred, obj in g:
# Check if there is at least one triple in the Graph
if (subj, pred, obj) not in g:
raise Exception("It better be!")
assert len(g) == 86, len(g)
g.close()
g.destroy(configuration=path)
The implementation of the rdflib-leveldb “LevelDB” Store depends on:
The leveldb library is installed using the appropriate package manager.
sudo apt install leveldb-dev
The implementation of the rdflib-leveldb “LevelDB” Store depends on a Python wheels package plyvel-wheels which includes platform-specific binaries for the leveldb library.
The task of installing a platform-specific Plyvel
wrapper is handled with:
pip install -r requirements.txt
(for standard use of this RDFLib Store)
or
pip install -r requirements.dev.txt
(for module development)
or just
python setup.py install