Search code examples
pythoncassandratitanbulbsrexster

Bulbs python Connection to a remote TitanDB + Rexster


I'm using TitanGraphDB + Cassandra. I'm starting Titan as follows

cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties

I have a Rexster shell that I can use to communicate to Titan + Cassandra above.

cd rexster-console-2.3.0
bin/rexster-console.sh

I'm attempting to model a network topology using Titan Graph DB. I want to program the Titan Graph DB from my python program. I'm using python bulbs package for that.My code to create the graph is as follows.

from bulbs.titan import Graph 
self.g = Graph()

Now I have rexster-console and Titan running on machine with IP Address 192.168.65.93.If my python application is runnnig on the same machine I use self.g = Graph().

What if I want to connect to the Titan AND Rexster running on machine with IP 192.168.65.93 from python application on 192.168.65.94

How do I do that? Can I pass some parameter (e.g a config file to Graph())? Where can I find it?


Solution

  • Simply set the Titan graph URI in the Bulbs Config object:

    >>> from bulbs.titan import Graph, Config
    >>> config = Config('http://192.168.65.93:8182/graphs/graph')
    >>> g = Graph(config)
    

    See Bulbs Config...

    And Bulbs Graph (note Titan's Graph class is a subclass of Rexster's Graph class)...

    And I encourage you to read through the Bulbs Quickstart and other docs because many of these questions are answered in there...

    The Quickstart uses bulbs.neo4jserver as an example, but since the Bulbs API is consistent regardless of the backend server you are using, the Quickstart examples are also relevant to Titan Server and Rexster.

    To adapt the Bulbs Quickstart for Titan or Rexster, simply change the Graph import from...

    >>> from bulbs.neo4jserver import Graph
    >>> g = Graph()
    

    ...to...

    >>> from bulbs.titan import Graph
    >>> g = Graph()
    

    ...or...

    >>> from bulbs.rexster import Graph
    >>> g = Graph()