0

I'm looking for some help getting this very simple query started, so I can build upon it. At the moment I'm not retrieving any results, but this query works in Protege.

from SPARQLWrapper import SPARQLWrapper, JSON, XML

sparql = SPARQLWrapper("http://dbpedia.org/sparql")

sparql.setQuery("""
    PREFIX pz: <http://protege.stanford.edu/ontologies/pizza/pizza.owl#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

    SELECT ?pizza
    WHERE {
        ?pizza rdfs:subClassOf pz:NamedPizza .
    }
""")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
Carson Lloyd
  • 13
  • 1
  • 4

1 Answers1

0

The query is being sent to DBpedia database.

The query contains pz:NamedPizza.

DBpedia does not have <http://protege.stanford.edu/ontologies/pizza/pizza.owl#> information so the query pattern does not match using the data of DBpedia.

When you query Protege it does have your local pizza data so the query has results.

AndyS
  • 16,345
  • 17
  • 21