问题
After 2 days of research I (a newby) still can't figure out what 'on disk' stores are available in RDFFlib 3.1.0. If you have a working example, that would be nice to see... For my app I prefer SQLite. I need no access to online RDF stores, I want to store info about relations inside the organisation in RDF. Thanks
回答1:
Here you have an example to make it work with MySQL. I don't think rdflib 3
works with SQLite.
import rdflib
from rdflib.Graph import ConjunctiveGraph as Graph
from rdflib import plugin
from rdflib.store import Store, NO_STORE, VALID_STORE
configString = "host=localhost,user=root,password=,db=db_name"
rt = store.open(configString,create=False)
assert rt == VALID_STORE,"The store is corrupted"
print "load store success"
graph = Graph(store)
g.parse("some.rdf")
g.commit()
I would avoid rdflib's on-disk stores since they seem to be not very reliable and don't scale very well. As you have noticed the documentation is not great either.
If you are doing some serious work then go for triple stores like Virtuoso or 4store and use SPARQL to access the data. There are many libraries to access them with Python.
来源:https://stackoverflow.com/questions/5868364/rdflib-on-disk-store