Skip to content

SPARQL queries don't work for Datasets #2356

@sdasda7777

Description

@sdasda7777

Hi, I tried to create a Dataset and query it with SPARQL, however I had no success. I retraced my steps to the SPARQL query example, which worked, however when I changed the container from Graph to Dataset, it stopped working. Curiously, it seems to work just fine with ConjunctiveGraph. My code looks like this:

from rdflib.graph import ConjunctiveGraph, Dataset, Graph

foaf="""[content of examples/foaf.n3]"""

#ds = Graph()
#ds = ConjunctiveGraph()
ds = Dataset()
ds.parse(data=foaf, format="n3")

for row in ds.query("SELECT ?s WHERE { [] foaf:knows ?s .}"):
    print(row)

I looked through open issues, and this one seems the most similar, but I don't think it is related, because when I parse it with Dataset, I can enumerate it and see that the data was in fact loaded (not sure if correctly, though).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions