vemonet / rdflib-endpoint

💫 Deploy SPARQL endpoints from RDFLib Graphs to serve RDF files, machine learning models, or any other logic implemented in Python
https://pypi.org/project/rdflib-endpoint
MIT License
75 stars 18 forks source link

SPARQL Updates #17

Closed steve-bate closed 11 months ago

steve-bate commented 11 months ago

The SPARQL endpoint doesn't support Delete and Insert. There's a comment in the code:

# TODO: RDFLib doesn't support SPARQL insert (Expected {SelectQuery | ConstructQuery | DescribeQuery | AskQuery}, found 'INSERT')

At least the current versions of the library does support it. However, the update processing uses different APIs than the query processing: prepareUpdate instead of prepareQuery and Graph.update instead of Graph.query. I'll investigate creating a PR to support updates.

https://rdflib.readthedocs.io/en/stable/intro_to_sparql.html#update-queries

vemonet commented 11 months ago

Hi @steve-bate thanks for the message, indeed we could easily support it if the docs states this, and I think I already have the piece of code to check if a query is an UPDATE or a SELECT commented somewhere

Feel free to send a PR (tag me in it to make sure I see it quickly)!

steve-bate commented 11 months ago

I have something working locally. I need to clean it up before submitting a PR, but at least it's a proof-of-concept. It works with the GUI too.

vemonet commented 11 months ago

Nice! Thanks a lot @steve-bate

If it is not too much to ask, could you also add 1 test to make sure using an insert and delete queries properly insert and delete from the RDFLib graph please? e.g. here, 1 test with a few queries: sends a triple to be inserted, check it is inserted, delete, check if deleted