This is my first time playing with SPARQL. I have created a query below but only getting the first 10000 results. How can I get all results from DBpedia?
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
PREFIX dbpedia0: <http://dbpedia.org/ontology/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
SELECT str(?song) as ?song str(?artist) as ?artist str(?genre) as ?genre WHERE {
?song a dbpedia0:Single.
?song dbpedia0:genre ?genre.
?song dbpedia0:musicalArtist ?artist
}
ORDER BY ?genre
""")
print '\n\n*** JSON Example'
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
for result in results["results"]["bindings"]:
print result["genre"]["value"].replace("http://dbpedia.org/resource/", "") +"\t\t"+result["artist"]["value"].replace("http://dbpedia.org/resource/", "")+"\t\t"+result["song"]["value"].replace("http://dbpedia.org/resource/", "")
I found something re: OFFSET
and LIMIT
, but I am not sure how to use it to get ALL results.