1

I tried

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
  • But I don't know what is 'g'. If I try different string say 'hello' it doesn't connect.
  • What is the equivalent of createDatabase with a name "my_database" to create a new graph?
  • How do I connect to an existing database with a name "my_database"?
cegprakash
  • 2,937
  • 33
  • 60

1 Answers1

1

The "g" must be an available GraphTraversalSource on the server you are connecting to at 'ws://localhost:8182/gremlin. The way in which you create "g" is dependent upon the graph database you are using. If you are using the open source Gremlin Server then, you configure that GraphTraversalSource by way an initialization script for the server as described in the "Starting Gremlin Server" section of the documentation. You can see an example of the creation of "g" in the sample script that ships with Gremlin Server also seen here. Neptune, CosmosDB, DSE Graph and perhaps JanusGraph on Compose have their own specific methods for "g" - you'd want to consult their documentation for more details.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • 1
    I use janusgraph. What should I do to create a graph with name "my_graph" and what should I do to connect to the graph later on? – cegprakash Jul 30 '18 at 11:56
  • JanusGraph packages Gremlin Server so you can use that method with the init script or their ConfiguredGraphFactory - https://docs.janusgraph.org/latest/configuredgraphfactory.html#configuring-JanusGraph-server-for-configuredgraphfactory – stephen mallette Jul 30 '18 at 12:07
  • ConfiguredGraphFactory.createConfiguration has a python equivalent? – cegprakash Jul 30 '18 at 12:13
  • Most graphs require configuration in their native language/APIs - for JanusGraph, that means Java/Groovy/JVM. There is no "Configuration API for Python" for JanusGraph. – stephen mallette Jul 30 '18 at 12:52
  • Do you mean I cannot use Python for janus graph development? Because I need to build a production ready codebase. – cegprakash Jul 30 '18 at 12:54
  • I also get this issue in Java https://stackoverflow.com/questions/51557469/illegalstateexception-gremlin-server-must-be-configured-to-use-the-janusgraphm – cegprakash Jul 30 '18 at 13:02
  • you can use python to interact with graphs in 2 ways: (1) write Gremlin in native python (2) send groovy-based scripts to Janus Server (which is just a packaged Gremlin Server). To configure the graph you can't do (1). The Gremlin language has no such constructs in Python and JanusGraph exposes no special python bindings for graph configuration. So, you must do (2) from python to interact with the graph at that level. – stephen mallette Jul 30 '18 at 13:03
  • 1
    too confusing :( I don't understand anything. Can't even create a graph named "my_graph" :( – cegprakash Jul 30 '18 at 13:05
  • i don't think you're following the instructions exactly as the configuration you posted in that other question doesn't match those in their documentation, but i'll let JanusGraph experts take it from here. My advice to you would be to simplify. Forget about JanusGraph for now. Work with a simple Gremlin Server/TinkerGraph. Make sure all that is working with Python so that you have "my_graph" and then reconfigure things to work with JanusGraph once you have some comfort. – stephen mallette Jul 30 '18 at 13:10
  • And if you don't understand my explanation above about the two ways python can interact with Gremlin Server, then you're missing the most fundamental aspects of how all of this connects together. Make sure you fully grasp that comment before proceeding further or I sense you will continue to struggle. – stephen mallette Jul 30 '18 at 13:12
  • https://stackoverflow.com/questions/51594838/janusgraph-please-add-a-key-named-configurationmanagementgraph-to-the-graph I tried the exact code in documentation but it always throws the same exception – cegprakash Jul 30 '18 at 13:15
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/177029/discussion-between-cegprakash-and-stephen-mallette). – cegprakash Jul 30 '18 at 13:45