python - 如何使用 SPARQL 将数据插入命名图?
问题描述
我正在使用 python 将数据插入到 blazegraph 中。我想指定插入数据的命名图,但我使用的代码触发了错误:
SPARQLWrapper.SPARQLExceptions.QueryBadFormed: QueryBadFormed: a bad request has been sent to the endpoint, probably the sparql query is bad formed.
如何解决此错误并将数据插入给定的命名图中?
from SPARQLWrapper import SPARQLWrapper, JSON, TURTLE, RDFXML
query='''
PREFIX dcterms: <http://purl.org/dc/terms/>
INSERT DATA {
GRAPH <http://example/shelf_A> {
<http://example/author> dcterms:name "author" .
<http://example/book> dcterms:title "book" ;
dcterms:author <http://example/author> .
}
}
'''
sparql =SPARQLWrapper("http://localhost:9999/blazegraph/namespace/kb/sparql")
sparql.setQuery(query)
sparql.method = 'POST'
sparql.query()
我还尝试从 blazegraph 的更新选项卡运行此查询,并发生相同的错误。我究竟做错了什么?
解决方案
推荐阅读
- python - 具有 __init_subclass__ 和子类注册表的注册表模式
- c# - 我应该如何在 .NET Core 2.2 中注册通用接口
- json - 使用 pljson 存储在 oracle apex 经典报告中的集合中的 Json 字符串
- javascript - 用于检查可用性的 Angular 验证器
- angular - 角度获取数组类型错误:无法读取未定义的属性“1”
- sql-server - 谷歌应用程序脚本 jdbc 连接中的“不支持集成安全性”
- ios - 协议问题中的 Swift 泛型类型。协议只能用作通用约束
- python - 如何修复以下代码中的损坏管道错误?
- python - 是否有在图像上应用置换贴图/矩阵的功能?
- jasmine - 量角器:如果元素未显示,则继续测试