This is What I wrote after importing rdflib and my owl data. I wrote 3 query part, and I couldnt take any answer from all. *
PREFIX : "<http://xmlns.com/foaf/0.1/>"
g = Graph()
g.bind("foaf", FOAF)
First one:
qres = g.query(
"""SELECT DISTINCT ?Name ?Microsoft
WHERE {
?a foaf:subclassof ?Microsoft .
?a foaf:Name ?Name .
?b foaf:Microsoft ?Microsoft .
}""")
for row in qres:
print("%s subclassof %s" % row)
from rdflib.namespace import FOAF
Second One:
qres = g.query('SELECT * WHERE { ?p a foaf:Engineers}', initNs={ 'foaf': FOAF })
for row in qres:
print("%s" % row)
Third One:
qres = g.query(
"""SELECT DISTINCT ?aName ?bOracle
WHERE {
?a foaf:individual_of ?b .
?a foaf:Name ?aName.
?b foaf:Oracle ?bOracle .
}""")
for row in qres:
print("%s individual_of %s" % row)