File: query.py

package info (click to toggle)
rudof 0.1.146%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 10,048 kB
  • sloc: python: 1,288; makefile: 32; sh: 1
file content (21 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pyrudof import Rudof, RudofConfig, QuerySolutions

rudof = Rudof(RudofConfig())
rdf = """prefix : <http://example.org/>
:alice a :Person ;
 :name "Alice"   ;
 :knows :bob     .
:bob a :Person   ;
 :name "Robert"  . 
"""
rudof.read_data_str(rdf)

query = """prefix : <http://example.org/>
select * where { 
  ?x a :Person 
}
"""

results = rudof.run_query_str(query)
for result in iter(results):
    print(result.show())