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

Querying a remote service with sparql AND selecting a graph fails (Solution included, but not tested for all but my use case) #2988

Open
jbekesi opened this issue Nov 19, 2024 · 0 comments

Comments

@jbekesi
Copy link

jbekesi commented Nov 19, 2024

Querying a remote service with sparql AND selecting a graph by URI fails, because
the match pattern for parsing the URL is greedy:

in rdflib/plugins/sparql/evaluate.py on line 347 (function evalServiceQuery the pattern
is "^service <(.*)>[ \n]*{(.*)}[ \n]*$",.

I changed this to "^service <(.*?)>[ \n]*{(.*)}[ \n]*$", and my use case worked.

The slightly changed example from https://rdflib.readthedocs.io/en/stable/intro_to_sparql.html#querying-a-remote-service will not work without the improved pattern:

qres = g.query(
    """
    SELECT ?s
    WHERE {
      SERVICE <https://dbpedia.org/sparql> {
         GRAPH <http://somegraph.uri.at> {
 
       ?s a ?o .
      }
    }
 }
    LIMIT 3
    """
)
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