I haven't figured out how to handle rdflib, so it's a provisional process. rdflib documentation
fuseki-server --mem --update --desc [ttl_file] /dataset
Code to add an RDF triple to the Fuseki server
rdf2fuseki.py
import rdflib
from rdflib import Graph,URIRef
if __name__ == '__main__':
#Preparation of RDF triple to add
bob = URIRef("http://example.org#bob")
like = URIRef("http://example.org#like")
tomato = URIRef("http://example.org#tomato")
#Ready for Endpoint
endpoint = r"http://localhost:3030/ds/query"
store = sparqlstore.SPARQLUpdateStore()
store.open((endpoint,r"http://localhost:3030/ds/update"))
#Graph to add
default_graph = URIRef('http://example.org/default-graph')
ng = Graph(store, identifier=default_graph)
ng.add((bob, like, tomato)) #Added to RDF Triple
RDF triples will be added, but the following warnings will appear and need improvement
WARN : Unrecognize request parameter (ignored): output
WARN : Unrecognize request parameter (ignored): format
WARN : Unrecognize request parameter (ignored): results
Recommended Posts