[英]How to connect Janusgraph deployed in GCP with Python runtime?
I have deployed the Janusgraph using Helm in Google cloud Containers, following the below documentation:我按照以下文档在 Google 云容器中使用 Helm 部署了 Janusgraph:
https://cloud.google.com/architecture/running-janusgraph-with-bigtable , https://cloud.google.com/architecture/running-janusgraph-with-bigtable ,
I'm able to fire the gremline query using Google Cloud Shell.我可以使用 Google Cloud Shell 触发 gremline 查询。
Snapshot of GoogleCLoud Shell谷歌云的快照 Shell
Now I want to access the Janusgraph using Python, I tried below line of code but it's unable to connect to Janusgraph inside GCP container.现在我想使用 Python 访问 Janusgraph,我尝试了下面的代码行,但它无法连接到 GCP 容器内的 Janusgraph。
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('gs://127.0.0.1:8182/gremlin','g'))
value = g.V().has('name','hercules').values('age')
print(value)
here's the output I'm getting这是我得到的 output
[['V'], ['has', 'name', 'hercules'], ['values', 'age']]
Whereas the output should be -而 output 应该是 -
30
Is there someone tried to access Janusgraph using Python inside GCP.是否有人试图在 GCP 中使用 Python 访问 Janusgraph。
You need to end the query with a terminal step such as next
or toList
.您需要使用诸如
next
或toList
类的终端步骤来结束查询。 What you are seeing is the query bytecode printed as the query was never submitted to the server due to the missing terminal step.您看到的是打印的查询字节码,因为由于缺少终端步骤,查询从未提交给服务器。 So you need something like this:
所以你需要这样的东西:
value = g.V().has('name','hercules').values('age').next()
print(value)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.