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

Allow sparql-execute-query to return simple list from select #78

Open
johanwk opened this issue Apr 14, 2024 · 0 comments
Open

Allow sparql-execute-query to return simple list from select #78

johanwk opened this issue Apr 14, 2024 · 0 comments

Comments

@johanwk
Copy link

johanwk commented Apr 14, 2024

The current sparql-execute-query always inserts query results into the current buffer. Could we have an option to return the results as a simple elisp list instead, so it can be bound to a variable, &c?

As a sketch: run the query with json result format in a temporary buffer (hopefully to handle multiline string values); apply json-parse-string to (buffer-string); transform into a simple list as return value.

The final RESULTS in the org-babel example below shows what I'd like to have directly from the query.

#+name: mysmall
#+begin_src sparql :url http://localhost:3030/bfo-core/query
select * {?x ?y ?z} limit 2
#+end_src

#+RESULTS:
| x              | y          | z                      |
|----------------+------------+------------------------|
| dc:contributor | rdf:type   | owl:AnnotationProperty |
| dc:contributor | rdfs:label | contributor            |

#+begin_src emacs-lisp :var result=mysmall() :results code :colnames no
result
#+end_src

#+RESULTS:
#+begin_src emacs-lisp
(("x" "y" "z")
 ("dc:contributor" "rdf:type" "owl:AnnotationProperty")
 ("dc:contributor" "rdfs:label" "contributor"))
#+end_src

PS. The main point here is to get the query results as a return value, rather than always inserted into the current buffer.

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

No branches or pull requests

1 participant