oxrdflib
oxrdflib copied to clipboard
Query objects are not supported as input to the query method
The query method of the OxigraphStore
does not accept rdflib Query
objects but only strings and otherwise fails with a TypeError
.
Example:
import rdflib
from rdflib.plugins.sparql import prepareQuery
from rdflib.namespace import DCTERMS
graph = rdflib.Graph(store='Oxigraph')
graph.add((rdflib.URIRef('http://localhost/example'), DCTERMS.title, rdflib.Literal('An arbitrary example')))
query_string = f'SELECT ?title WHERE {{?obj <{DCTERMS.title}> ?title}}'
query_object = prepareQuery(query_string)
# This works:
result = graph.query(query_string)
print(list(result)[0][0])
# This does not work:
result = graph.query(query_object)
print(list(result)[0][0])
Maybe the line https://github.com/oxigraph/oxrdflib/blob/b8008f26209e363a79a4a386bf065564f3a181bc/oxrdflib/init.py#L110 should rather read if isinstance(query, Query) or kwargs
for the time being?
In the long term, it would be great if prepared Query
objects could be supported. Maybe this could result in even further speed ups? Probably this is related to https://github.com/oxigraph/oxrdflib/issues/11 as well.
Thanks a lot for your efforts!