performing sparql query on the rdf data stored in

2019-09-10 21:03发布

问题:

I have stored large amount of RDF data into a relational database with the help of rdflib_sqlalchemy.SQLAlchemy.Now I want to execute Sparql query over the same.I can not find any thing to know how to implement sparql query here. Can anyone help.

回答1:

Including sample code would make it easier to know what you are after but see the documentation on querying an RDFLib graph with SPARQL.

Using the example from the rdflib-sqlalchemy README where graph is the name of the open graph.

rq = "select ?s where {?s ?p ?o} limit 10"

results = graph.query(rq)
for row in results:
    print row.s