英文:
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:
https://cloud.google.com/architecture/running-janusgraph-with-bigtable,
I'm able to fire the Gremlin query using Google Cloud Shell.
Snapshot of Google Cloud Shell
Now I want to access the Janusgraph using Python. I tried the below line of code, but it's unable to connect to Janusgraph inside the GCP container.
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:
[['V'], ['has', 'name', 'hercules'], ['values', 'age']]
Whereas the output should be:
30
Is there someone who has tried to access Janusgraph using Python inside GCP?
英文:
I have deployed the Janusgraph using Helm in Google cloud Containers, following the below documentation:
https://cloud.google.com/architecture/running-janusgraph-with-bigtable,
I'm able to fire the gremline query using Google Cloud 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.
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
[['V'], ['has', 'name', 'hercules'], ['values', 'age']]
Whereas the output should be -
30
Is there someone tried to access Janusgraph using Python inside GCP.
答案1
得分: 1
你需要以终端步骤,如 next
或 toList
结束查询。您看到的是查询字节码,因为由于缺少终端步骤,查询从未提交到服务器。所以您需要类似这样的内容:
value = g.V().has('name','hercules').values('age').next()
print(value)
英文:
You need to end the query with a terminal step such as next
or 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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论