首页 > 解决方案 > 使用 SPARQL 查询从 Neptune DB 检索数据

问题描述

我正在尝试使用 SPARQL 查询从 Neptune DB 中检索数据。我从本地 Jupyter Notebook 连接到与 Neptune 具有相同 VPC 的 EC2 实例。但是查询没有检索任何数据并且标准输出为空,我不确定我哪里出错了。任何帮助将不胜感激。请在下面找到查询。

stdin, stdout, stderr = ssh.exec_command(
' curl https://.cluster-.us-east1.neptune.amazonaws.com:8182/sparql \-d "query=PREFIX mol: <http://www.semanticweb.org/25#>\
   SELECT * WHERE {?s ?p ?o } LIMIT 1" \ -H "Accept: text/csv"')

先感谢您。

标签: sparqlrdfamazon-neptune

解决方案


您可能会遇到 cURL 的问题。cURL 存在多行输入问题(例如 SPARQL 查询)。最好使用以下格式:

curl 'https://cluster.cluster.us-east-2.neptune.amazonaws.com:8182/sparql' \
    -H "Accept: text/csv" \
    --data-urlencode query='
    PREFIX mol: <http://www.semanticweb.org/25#> 
    SELECT * WHERE { ?s ?p ?o } LIMIT 1'

推荐阅读