[redland-dev] SPARQL queries for Virtuoso in Python bindings
Rimvydas
naktinis at gmail.com
Sun May 9 22:24:10 CEST 2010
I have set up Virtuoso DB on my machine and I can successfully query it
using ODBC's ISQL and Virtuoso's ISQL environments. However, I have no luck
trying to do the same thing using librdf's Python bindings:
Let's add a triple:
$ rdfproc -r xml -s virtuoso -t "user='usr',password='psw',dsn='VOS'"
somecontext add aa bb cc
rdfproc: added triple to the graph
Make sure it is actually added:
CALL DB.DBA.SPARQL_EVAL('SELECT * FROM NAMED <somecontext> {GRAPH
<somecontext> {?s ?p ?o}}', NULL, 0)
...
1 row fetched
Try doing the same using librdf in Python:
>>> store = RDF.Storage(storage_name="virtuoso", name="somecontext",
options_string="dsn='VOS',user='usr',password='psw'")
>>> model = RDF.Model(store)
>>> query = RDF.SPARQLQuery('SELECT * WHERE {?s ?p ?o}')
>>> results = query.execute(model)
>>> results.next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/RDF.py", line 2022, in next
raise StopIteration
StopIteration
Here I get 0 results. Storage seems to be initialized successfully, but
maybe there's something with context or the way I use model?
Any hint what could be wrong?
--
Rimvydas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.librdf.org/pipermail/redland-dev/attachments/20100509/92de19c6/attachment.htm
More information about the redland-dev
mailing list