With rdflib SPARQL support being way to experimental this could offer a nice
replacement for in-memory storage.
Not all functionality is implemented and some test fail, however resources can
be stored and queried.
Initializing the store:
>>> store = surf.Store(**{"reader": "librdf", "writer" : "librdf"})
Librdf also claims to support certain other storage engines, I haven't tried
them yet though.
-Christoph
--
You received this message because you are subscribed to the Google Groups "surfrdf" group.
To post to this group, send email to sur...@googlegroups.com.
To unsubscribe from this group, send email to surfrdf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/surfrdf?hl=en.
Am Dienstag, 23. August 2011 schrieb Dominique Guardiola Falco:
> Surf can create a store, load some data, use things like get_class over it,
> but when I query it I always get a NoneType (either in raw and programmatic
> queries)
> wondering if it's the same for everyone else (or just me)
I've never gotten around to properly implement execute_sparql (which is not a
core concept to SuRF). If you look at the plugin implementation, you'll see
the code is commented out.
SuRF's default behaviour is to return "None" if the method is not implemented.
I believe in some places it would be better to raise a NotImplementedError.
Here's a similar query that does work:
>>> import surf
>>> uri="http://www.w3.org/People/Berners-Lee/card.rdf"
>>> mystore = surf.Store(**{"reader": "librdf", "writer" : "librdf"})
>>> mystore.load_triples(source=uri)
True
>>> mystore.size()
78
>>> from surf.query import *
>>> q = mystore.reader._execute(select('?s', '?p', '?o').where(('?s', '?p',
'?o')))
>>> q = mystore.reader._execute(select('?s', '?p', '?o').where(('?s', '?p',
'?o')))
>>> list(q)
[{'p': <RDF.Node object at 0x1f06290>, 's': <RDF.Node object at 0x1f06390>,
'o': <RDF.Node object at 0x1f062d0>}, {'p': <RDF.Node object at 0x1f06450>,
's': <RDF.Node object at 0x1f06190>, 'o': <RDF.Node object at 0x1f063d0>},
...
You can try to use the mystore.reader._to_table() method to convert the output
q into rdflib types.
It shouldn't be too difficult to complete execute_sparql, it is basically all
about returning a proper JSON result, similar to the other plugins.
Hope this helps
-Christoph
There are 7 failing tests for the experimental librdf plugin (of total 56) of
which
- 3 can be attributed to missing support for execute_sparql() (see mail from 2
days ago)
- 3 seem to stem from a different interpretation on context on librdf's side
(or so I believe)
- 1, I am not completely sure, might be the same as the preceding 3.
I tried to read on librdf's documentation on context, but didn't make it
through the whole page: http://librdf.org/notes/contexts.html
-Christoph
> I'm testing the sparql plugin to access a D2R server (Joseki + ARQ)
> surf fails on a simple query, but this query works when testing it directly
> on the server (through a js interface)
I think this is due to a spelling error in your code "endproint".
However your might find that the SuRF sparql protocol plugin doesn't properly
work with Joseki. I haven't been able to setup Joseki to be able to write to
it, so I couldn't properly test. However somebody on GitHub implemented a
joseki_sparql plugin, maybe this is what you need:
https://github.com/bollwyvl/surf/commits/surfrdf
> AFAIK, librdf is not in the loop, I just created a sparql store with surf.
> But the strange thing is that librdf is around because everytime I load it,
> it throws 3 errors - but works (perhaps a problem on my side when
> installing it seems, I opened an issue here :
> http://bugs.librdf.org/mantis/view.php?id=460 )
>
> could there be a conflict between surf and librdf "RDF" namespace ?
>
> >>> import surf
> >>> from surf.query import *
> >>> store = surf.Store( reader = 'sparql_protocol',
>
> ... endproint = 'http://localhost:2020/sparql',
> ... default_graph = 'http://localhost:2020')
> librdf error - storage postgresql already registered
> librdf error - storage virtuoso already registered
> librdf error - query language vsparql already registered
I can't reproduce this error. I did setup a clean environment, install surf
from scratch and add the librdf plugin:
$ virtualenv env
$ source env/bin/activate
$ easy_install -U surf surf.sparql_protocol
$ cd /tmp/surf/plugins/surf.librdf/
$ python setup.py sdist
$ pip install dist/surf.librdf-1.0.0.tar.gz
No error messages here. Have you by any chance to installations of the SuRF
librdf plugin, so that SuRF finds it twice?
> By the way, has the developement migrated on github or is it still on svn ?
No, the fork on github is just a private one. It is currently updated
automatically, so changes from svn should be pulled over. Not to obvious, but
the surfrdf branch has the upstream source, while master has things I played
with. I just probably move the librdf plugin to svn, as it seems usable.
-Christoph
Sorry, should've said "Have you by any chance *two* installations"
I tried to setup Joseki and get the same endpoint for read & write access,
however this failed. If you succeed in making this work, please do document
how you did it.
-Christoph