How can we ask federated queries using SPARQLWrapper? If it is not possible, is there any alternate library available for making such queries for Python?
Asked
Active
Viewed 795 times
1
-
1We'll need more information. (Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself.) How have you tried to run federated SPARQL queries so far? Typically this is done with the `service` keyword. What didn't work? Also, questions asking for libraries or tools are off topic, so if SPARQLWrapper doesn't handle this, StackOverflow isn't really the right place to ask. – Joshua Taylor Sep 26 '13 at 17:11
1 Answers
1
You can ask federated queries the same way as normal queries just by adding the SERVICE keyword.
Below you may find an example on the endpoint of sparql.org (according to http://answers.semanticweb.com/questions/1830/federated-sparql-on-sparqlorg)
from SPARQLWrapper import SPARQLWrapper
sparql = SPARQLWrapper("http://sparql.org/sparql")
sparql.setQuery("""
select *
from <http://xmlns.com/foaf/0.1/> # bogus, not used
{
service <http://dbpedia.org/sparql> {
[] a ?Concept
}
}
limit 10
""")
results = sparql.query()
results.print_results()
Of course, the chosen endpoint have to able to handle the federated query.

Stanislav Kralin
- 11,070
- 4
- 35
- 58

mgraube
- 380
- 1
- 14
-
basically the sparql wrapper is agnostic with respects to the query evaluation, which is evaluated by the provided endpoint – wikier Nov 07 '13 at 20:22