in memory triple store
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.rst
minisparql.py
requirements.txt
test_minisparql.py

README.rst

Mini Sparql

Mini sparql is an experiment in writing a simple (in memory) triple store. It can be used to read in files or triple data, which can be queried using sparql. It's by no means complete, but does provide most of sparql 1.0.

Examples

Assuming you have triple data like:

robin name Robin .
robin size small .
robin color red .
robin color brown .
robin legs 2 .
sparrow name Sparrow .
sparrow size small .
sparrow color brown .
bluetit name Bluetit .
bluetit size small .
bluetit color blue .
bluetit color green .
eagle name Eagle .
eagle size large .
eagle color brown .

In a file called birds.ttl, then you can run minisparql and query the data:

$ python minisparql.py birds.ttl
sparql> SELECT ?name ?color WHERE { ?id name ?name . ?id color ?color }
name, color
'Bluetit', 'blue'
'Bluetit', 'green'
'Eagle', 'brown'
'Robin', 'brown'
'Robin', 'red'
'Sparrow', 'brown'
sparql> SELECT ?name WHERE { ?id name ?name . ?id color red }
name
'Robin'

Filters are supported too:

sparql> SELECT ?name WHERE { ?id name ?name FILTER regex(?name, "r", "i") }
name
'Robin'
'Sparrow'

As well as using the interactive prompt it is possible to execute queries via the -e switch:

$ python minisparql.py birds.ttl -e 'SELECT ?name WHERE { ?id name ?name FILTER regex(?name, "r", "i") }'
name
'Robin'
'Sparrow'