There is now some rudimentary support for a Virtuoso backed store in RDFLib. Basic usage is as follows:
from rdflib.store import Store from rdflib.plugin import get as plugin Virtuoso = plugin("Virtuoso", Store) store = Virtuoso("DSN=VOS;UID=dba;PWD=dba;WideAsUTF16=Y")
and then use this store as you would any other. This has been tested with rdflib3 only and may or may not work with rdflib2.
With RDFLib 3 there is support for using Virtuoso’s SPARQL directly from the Graph.query. There are some outstanding questions about how this will behave with multiple sparql implementations...
NOTE the way Virtuoso handles cursors might be unexpected. A store will acquire a cursor on demand but when operations with it have finished it is important to release it. This is done by calling the graph (or the store)’s commit or rollback methods. Be sure to do this frequently especially for long running processes that may keep a store around for long periods of time.
RDFLib Storage backed by Virtuoso
Acquire a cursor, setting the isolation level.
Run a SQL query on the connection optionally with the supplied cursor. If the cursor is not specified one will be allocated and kept until commit() or rollback() is called.
Run a SPARQL query on the connection. Returns a Graph in case of DESCRIBE or CONSTRUCT, a bool in case of Ask and a generator over the results otherwise.
Commit any pending work. Also releases the cached cursor.
Roll back any pending work. Also releases the cached cursor.
Takes the Virtuoso representation of an RDF node and returns an appropriate instance of rdflib.term.Node.