1

I'm following this tutorial:

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-python.html

How can I add a node and then retrieve the same node?

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://your-neptune-endpoint:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)

print(g.V().limit(2).toList())
remoteConn.close()

All the above right now is doing is retrieving 2 nodes right?

1
  • The question is not clear. Did you mange to connect to Neptune and run the query? If not, can you provide more information on the error message you receive. Commented Aug 31, 2019 at 19:37

1 Answer 1

2

If you want to add a vertex and then return the information about the vertex (assuming you did not provide your own ID) you can do something like

newId = g.addV("mylabel").id().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.