Bulbs python 连接远程 TitanDB + Rexster
我正在使用TitanGraphDB和Cassandra。我是这样启动Titan的:
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
我有一个Rexster控制台,可以用来和上面的Titan和Cassandra进行交流。
cd rexster-console-2.3.0
bin/rexster-console.sh
我想用Titan图数据库来建模一个网络拓扑。我希望能通过我的Python程序来操作Titan图数据库。为此,我使用了一个叫做python bulbs
的包。创建图的代码如下:
from bulbs.titan import Graph
self.g = Graph()
现在,我的rexster控制台和Titan都在IP地址为192.168.65.93
的机器上运行。如果我的Python应用程序也在同一台机器上运行,我就可以用self.g = Graph()
来连接。
但如果我想从IP地址为192.168.65.94
的Python应用程序连接到运行在192.168.65.93
上的
我可以传递一些参数(比如一个配置文件给Graph())吗?我在哪里可以找到这些信息呢?
1 个回答
2
只需要在Bulbs的Config
对象中设置Titan图的URI:
>>> from bulbs.titan import Graph, Config
>>> config = Config('http://192.168.65.93:8182/graphs/graph')
>>> g = Graph(config)
可以查看Bulbs的Config
...
- http://bulbflow.com/docs/api/bulbs/config/
- https://github.com/espeed/bulbs/blob/master/bulbs/config.py
还有Bulbs的Graph
(注意Titan的Graph
类是Rexster的Graph
类的子类)...
- http://bulbflow.com/docs/api/bulbs/rexster/graph/
- https://github.com/espeed/bulbs/blob/master/bulbs/titan/graph.py
我建议你阅读Bulbs的快速入门和其他文档,因为很多问题在里面都有解答...
快速入门使用bulbs.neo4jserver
作为示例,但由于Bulbs的API在使用不同后端服务器时是一致的,因此快速入门中的示例同样适用于Titan服务器和Rexster。
要将Bulbs的快速入门适配到Titan或Rexster,只需将Graph
的导入从...
>>> from bulbs.neo4jserver import Graph
>>> g = Graph()
...改为...
>>> from bulbs.titan import Graph
>>> g = Graph()
...或者...
>>> from bulbs.rexster import Graph
>>> g = Graph()