【发布时间】:2019-11-16 15:57:55
【问题描述】:
我有一个 Fuseki 端点,想使用 python rdflib 库向它添加图形。
我连接到Fuseki服务器如下:
import rdflib
from rdflib import Graph, Literal, URIRef
from rdflib.plugins.stores import sparqlstore
query_endpoint = 'http://localhost:3030/dsone/query'
update_endpoint = 'http://localhost:3030/dsone/update'
store = sparqlstore.SPARQLUpdateStore()
store.open((query_endpoint, update_endpoint))
然后我设置一个 rdflib ConjunctiveGraph 如下:
g = rdflib.ConjunctiveGraph(identifier=URIRef("http://localhost/dsone/g3"))
g.parse(data="""
@base <http://example.com/base> .
@prefix : <#> .
<> a :document1 .
""", format='turtle', publicID = "http://example.com/g3")
g 现在包含一个三元组:
for r in g:
print(r)
结果:
(rdflib.term.URIRef('http://example.com/base'), rdflib.term.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), rdflib.term.URIRef('http://example.com/base#document1'))
现在我将图表添加到商店:
store.add_graph(g)
服务器显示200 返回码。当我直接通过 REST 进行插入时,它返回 204 - 这可能是一个线索。
现在商店里什么都没有了。
for r in store.query("""
select ?g (count(*) as ?count) {graph ?g {?s ?p ?o .}} group by ?g
"""):
print(r)
没有输出。
据我所知,store.add_graph(g) 什么都不做。
有什么想法吗?
【问题讨论】: