是的,AWS Neptune支持一次性提交多个OpenCypher语句到HTTPS端点。您可以使用batch
参数来实现这一点。
以下是一个示例代码,演示如何通过HTTPS端点一次性提交多个OpenCypher语句:
import requests
import json
# Neptune HTTPS endpoint URL
url = "https://your-neptune-endpoint:8182"
# OpenCypher statements
statements = [
"CREATE (n:Person {name: 'Alice'})",
"CREATE (n:Person {name: 'Bob'})",
"MATCH (n:Person) RETURN n",
]
# Build the request payload
payload = {
"gremlin": "\n".join(statements),
"accept": "application/json",
}
# Send the request
response = requests.post(url, json=payload)
# Parse the response
data = json.loads(response.content)
for result in data["result"]["data"]:
print(result["row"])
在上述示例中,我们首先定义了Neptune的HTTPS端点URL,然后定义了要执行的多个OpenCypher语句。接下来,我们构建了请求的有效载荷,其中gremlin
参数包含了多个OpenCypher语句,使用\n
分隔。然后,我们发送POST请求,并解析响应数据。
请确保将your-neptune-endpoint
替换为您实际使用的AWS Neptune端点URL。另外,您可能需要进行适当的身份验证和授权,具体取决于您的AWS Neptune设置。