0

i am developing a server that uses a Jena triple store. The server is developed in Python, and I am using the SPARQLWrapper library to handle the different operations to be performed. I had no problems in querying the store (SELECT operation) and to create triples (INSERT DATA operation). Things are a bit more tricky with the DELETE operation. I am trying to execute:

q= 
'PREFIX pref:<url>
 DELETE {?s ?p ?o}
WHERE {
 ?s a  pref:class.
}'

On the url /update. I receive a response that the operation is OK (HTTP code 200), but the triples are still on my store (checked through a SELECT operation).

wrapper = SPARQLWrapper(<my_url>/update)
wrapper.setMethod('DELETE')
wrapper.query(q)

I tried different HTTP verbs (POST, DELETE) to see if that could make a difference, but nothing changes.

Also I am running the fuseki-server with the --update option.

1 Answers1

0

you need to define the variables ?p and ?o

for instance:

DELETE {?s ?p ?o}
WHERE {
 ?s ?p ?o .
 ?s a  prefix:class
}

see here also

durschtnase
  • 156
  • 2
  • 7
  • Thanks! Unfortunately, it does not help and I still see the data I need to delete, into the store. – PeioBourreau Nov 08 '17 at 13:11
  • could you please post an example of how you added the data to the store.. the example above only deletes data from the default graph.. if you store the data somewhere else you need to specify the graph too – durschtnase Nov 08 '17 at 13:18
  • Need to define `prefix:`. Then make sure `SELECT * WHERE {?s ?p ?o . ?s a prefix:class` matches something. The operation is POST, not DELETE. – AndyS Nov 08 '17 at 15:19
  • to insert a data, I use a basic INSERT DATA operation: INSERT DATA {pref:342342 pref:rel_id pref:class} for instance – PeioBourreau Nov 08 '17 at 17:30
  • `PREFIX pref:` is wrong. You have to use an absolute URL (http:// or urn:) and match it to the data. wil b resolved by the parser and made into something unexpected. – AndyS Nov 08 '17 at 21:44
  • There was a syntax mistake in my query... problem solved. Sorry and thanks for the help! – PeioBourreau Nov 10 '17 at 09:49