diff options
author | Gunnar Aastrand Grimnes <gromgull@gmail.com> | 2013-04-25 13:39:53 +0200 |
---|---|---|
committer | Gunnar Aastrand Grimnes <gromgull@gmail.com> | 2013-04-25 13:39:53 +0200 |
commit | bb10be680fcd61492201b0ece87e841d521cca71 (patch) | |
tree | 8adb6addcb52f5171095ad0b81edc98ce4d5e994 /examples/prepared_query.py | |
parent | 9f0814e3050b040f531092f985dc8c6539e9e351 (diff) | |
download | rdflib-bb10be680fcd61492201b0ece87e841d521cca71.tar.gz |
example cleanup - copy examples from rdflib-sparql
Diffstat (limited to 'examples/prepared_query.py')
-rw-r--r-- | examples/prepared_query.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/prepared_query.py b/examples/prepared_query.py new file mode 100644 index 00000000..808dd558 --- /dev/null +++ b/examples/prepared_query.py @@ -0,0 +1,30 @@ + +""" + +Prepared Queries Example +------------------------ + +Queries be prepared (i.e parsed and translated to SPARQL algebra) +by + +rdlfib.plugins.sparql.prepareQuery + +When executing, variables can be bound with the +initBindings keyword parameter + +""" + +import rdflib +from rdflib.plugins.sparql import prepareQuery + + +q = prepareQuery( + 'select ?s where { ?person <http://xmlns.com/foaf/0.1/knows> ?s .}') + +g = rdflib.Graph() +g.load("foaf.rdf") + +tim = rdflib.URIRef("http://www.w3.org/People/Berners-Lee/card#i") + +for row in g.query(q, initBindings={'person': tim}): + print row |