1

I am trying to connect to Neptune using Python from EC2 instance.

Python code:

from __future__  import print_function  # Python 2/3 compatibility

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()

remoteConn = DriverRemoteConnection('wss://my_end_point:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)

print(g.V().has("system.tenantId", "sample_tenantId").count())
remoteConn.close()

rather than executing gremlin query . its giving output as it is

output:

    [['V'], ['has', 'system.tenantId', 'sample_tenantId'], ['count']]

question: why its not taking gremlin query?

Please note: Connection is proper and I got output as mentioned in the link: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-python.html

output:    [v[sample_RETURN_D_H], v[sample_IND]] 

1 Answer 1

2

Gremlin queries are lazily evaluated, so you must add a terminal step to your query for it to be executed by the server. If you change your line to add one of these steps as shown below, then it will be executed by the server.

print(g.V().has("system.tenantId", "sample_tenantId").count().next())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.