Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support INSERT queries #65

Closed
barrynl opened this issue Aug 4, 2017 · 5 comments
Closed

Support INSERT queries #65

barrynl opened this issue Aug 4, 2017 · 5 comments

Comments

@barrynl
Copy link

barrynl commented Aug 4, 2017

Hi all,

I'm trying to use GRLC to insert data into a triple database, but the query does not show up in the interface and the GRLC logs show this message:

ParseException: Expected {SelectQuery | ConstructQuery | DescribeQuery | AskQuery}

Apparently, only retrieval of data is supported. Are there any plans for supporting INSERT queries?

Kind regards, Barry

@barrynl
Copy link
Author

barrynl commented Aug 4, 2017

Hi, I've tried to find out why GRLC does not support this; starting from the following error in the log:

Traceback (most recent call last):
   File "/home/grlc/grlc/src/gquery.py", line 194, in get_metadata
     parsed_query = translateQuery(Query.parseString(rq, parseAll=True))
   File "/usr/local/lib/python2.7/site-packages/pyparsing.py", line 1129, in parseString
     raise exc
 ParseException: Expected {SelectQuery | ConstructQuery | DescribeQuery | AskQuery} (at char 473), (line:13, col:14)

It seems to be related to the rdflib Query.parseString calls in the gquery.py file. From the rdflib code, this function only supports read queries (see rdflib). Maybe GRLC should try this one as well, when parsing queries.

@albertmeronyo
Copy link
Member

Hi @barrynl ,

Thanks for posting this. Support for anything other than SELECT has been so far rudimentary, but please check out 53a886c for a basic INSERT implementation.

Basically I've followed your advice and used rdflib's UpdateUnit. This comes with two important caveats:

  • Implementations for INSERT vary among endpoints. So far I've been unable to check Virtuoso, but maybe you work with another triplestore/queries? A working API is at https://github.com/albertmeronyo/grlc-insert
  • UpdateUnit doesn't support parsing variables (they don't make much sense in INSERT), which means we can't map them to call parameters (at least not trivially). I'd be interested in knowing your thoughts about this

Other than this, SELECT queries are translated into GET and INSERTS into POST in the generated specs, unless otherwise stated.

@barrynl
Copy link
Author

barrynl commented Aug 22, 2017

Hi @albertmeronyo ,

Thanks for the effort!

Concerning your caveats:

  • I'm currently only using Apache Jena Fuseki.
  • You are absolutely right. 😆 I had not realized that INSERT queries obviously do not come with variables. This, however, is a requirement in my use case, so I have to think about this a bit more.

My use case is that I want to let a user fill in the Swagger parameter values (or call the API in some other way) and insert those values into a repository. This, however, is only possible if we add variables inside the INSERT queries, but, as you mentioned, this would make them invalid to the SPARQL 1.1 Update specs. One way to circumvent this, would be to loosen the requirement that the SPARQL queries should be valid BEFORE SUBSTITUTION to the requirement that AFTER SUBSTITUTION the SPARQL queries should be valid. This however, is a deviation from the way GRLC currently works.

Regards, Barry

@barrynl
Copy link
Author

barrynl commented Aug 24, 2017

Another issue with supporting Updates through GRLC is whether users should also generate the unique URIs themselves (which requires a bit of Semantic Web knowledge) or would GRLC do this for them.

The longer I think about this issue, the less sure I am that it fits GRLC.

Regards, Barry

@c-martinez
Copy link
Collaborator

It looks like insert via grlc will not be supported, at least not in the near future. Please reopen this issue if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants