使用Python和RDFLib为Virtuoso triplestore添加三元组

时间:2013-11-20 12:08:32

标签: python virtuoso rdflib

我需要制作一个程序,将三元组添加到Virtuoso triplestore,我正在使用Python和RDFLib。 我安装了Virtuoso插件并尝试了http://pythonhosted.org/virtuoso/rdflib.html#virtuoso-storage中的连接。我得到了:

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")
似乎它没有问题,问题是:现在是什么?如何添加新的三元组?我试过了:

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')

产生了以下错误:

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

问题是这有什么问题?以及如何正确添加三元组? 感谢。

0 个答案:

没有答案