INSERT/DELETE/UPDATE query using SPARQLWrapper

后端 未结 2 1771
孤独总比滥情好
孤独总比滥情好 2021-01-18 09:24

Although I have gone through lot of examples on the web explaining the use of python SPARQLWrapper using SELECT statements for fetching data from sesame triple store, but no

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 09:52

    This is not particularly clear from the docs, but I think you can just execute an update statement in the same way that you execute a query:

    queryString = "DELETE WHERE { ?s ?p ?o. }" 
    sparql = SPARQLWrapper("http://localhost:8080/openrdf-sesame/repositories/test/statements")
    
    sparql.setQuery(queryString) 
    ret = sparql.query()
    

    In the case of Sesame, one thing to keep in mind is that the URL for the update endpoint (repositories//statements) is not the same as the URL for the query endpoint (repositories/). See the Sesame protocol docs for details.

提交回复
热议问题