我一直有这个奇怪的问题,我正在尝试使用 python 中的 SPARQLWrapper 库插入一个大师图。我可以通过基于浏览器的端点插入三元组localhost:8890\sparql
,但是当我通过我的 python SparqlWrapper 尝试相同的查询时,它会引发以下错误:
SPARQLWrapper.SPARQLExceptions.QueryBadFormed:QueryBadFormed:错误请求已发送到端点,可能是 sparql 查询格式错误。
我觉得配置结束时有问题,但无法识别。
PREFIX dbpedia: <http://dbpedia.org/resource/> Insert Data { GRAPH <test> { <http://dbpedia.org/resource/life> <http://umbel.org/umbel/rc/Artist> '2' . } }
Traceback (most recent call last):
File "test.py", line 33, in <module>
sys.exit(process.run("1"))
File "test.py", line 27, in run
result = self.sparql.query().convert()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py", line 390, in query
return QueryResult(self._query())
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py", line 363, in _query
raise QueryBadFormed()
SPARQLWrapper.SPARQLExceptions.QueryBadFormed: QueryBadFormed: a bad request has been sent to the endpoint, probably the sparql query is bad formed.