Adding triples to Virtuoso triplestore with Python and RDFLib
Asked Answered
K

0

6

I need to make a program to add triples to a Virtuoso triplestore, I'm using Python and RDFLib. I've installed the Virtuoso plugin and tried a connection as seen in http://pythonhosted.org/virtuoso/rdflib.html#virtuoso-storage. I got:

from rdflib.graph import ConjunctiveGraph as Graph
from rdflib.store import Store
from rdflib.plugin import get as plugin
from rdflib.term import URIRef, Literal

Virtuoso = plugin("Virtuoso", Store)
store = Virtuoso("DSN=VOS;UID=dba;PWD=dba;WideAsUTF16=Y")

It seems that it has no problems, the matter is: now what? How to add the new triples? I tried:

default_graph_uri = "http://llisa.dlsi.uji.es/productset/"
graph = Graph(store,identifier = URIRef(default_graph_uri))
graph.add((URIRef("http://llisa.dlsi.uji.es/productset#0g9x91t"),URIRef("http://xmlns.com/foaf/0.1/nick"),Literal("The Car")))
store.commit()
print graph.serialize(format='pretty-xml')

that produced the following error:

File "/usr/local/lib/python2.7/dist-packages/virtuoso-0.12-py2.7.egg/virtuoso/vstore.py", line 345, in resolve
(value, dvtype, dttype, flag, lang, dtype) = args
ValueError: need more than 4 values to unpack

The question is What's the problem with that? and How do I add the triples properly? Thanks.

Kukri answered 20/11, 2013 at 12:8 Comment(1)
Questions specifically regarding Virtuoso (virtuoso.openlinksw.com) are generally best raised on the public OpenLink Discussion Forums (boards.openlinksw.com/support), the Virtuoso Users mailing list (sourceforge.net/mailarchive/forum.php?forum_name=virtuoso-users), or through a confidential Support Case (support.openlinksw.com/support/online-support.vsp).Jara

© 2022 - 2024 — McMap. All rights reserved.