Deleting triples from in all graphs in a dataset (Fuseki)

454 views
Skip to first unread message

scossu

unread,
Dec 19, 2017, 6:15:59 PM12/19/17
to rdflib-dev

Hello,

Having the following mock data set, backed by Jena Fuseki, with a triple in a graph:

>>> store = SPARQLUpdateStore(queryEndpoint='http://localhost:3030/dev/query', update_endpoint='http://localhost:3030/dev/update')
>>> ds = Dataset(store, default_union=True)
>>> gr = ds.graph(URIRef('urn:g:1'))
>>> gr.add((URIRef('urn:s:1'), URIRef('urn:p:1'), URIRef('urn:o:1')))

I want to delete that triple without knowing which graph it is in, considering that there may be many other graphs and triples in the data set.

In SPARQL that would correspond to:

DELETE {
   GRAPH ?g {
     <urn:s:1> <urn:p:1> <urn:o:1> .
  }
} WHERE {}

I *must* specify a graph, either by IRI or variable, or Fuseki won't remove the triple—i.e. something like

>>> ds.remove((URIRef('urn:s:1'), URIRef('urn:p:1'), URIRef('urn:o:1')))

or even

>>> ds.remove((URIRef('urn:s:1'), URIRef('urn:p:1'), URIRef('urn:o:1'), None))

won't work.

How would I do that in RDFLib?

Thanks,
Stefano
Reply all
Reply to author
Forward
0 new messages