docs: clarify the use of an identifier when persisting a triplestore by wimmuskee · Pull Request #654 · RDFLib/rdflib (original) (raw)
Well, simple using the Graph to persist and open does not work without an identifier (that would be the default use case for me).
So,
from rdflib import Graph from rdflib import URIRef, Literal from rdflib.namespace import RDFS
g = Graph("Sleepycat") g.open("mystore", create=True) g.add((URIRef("https://github.com/RDFLib"),RDFS.label,Literal("RDFlib Github homepage", lang="en"))) print("triples added: " + str(len(g)))
prints 1
g.close()
g = None
g = Graph("Sleepycat") g.open("mystore", create=False) print("triples added: " + str(len(g)))
prints 0
g.close()