我正在使用 TitanGraphDB + Cassandra。我按如下方式启动 Titan
cd titan-cassandra-0.3.1
bin/titan.sh config/titan-server-rexster.xml config/titan-server-cassandra.properties
我有一个 Rexster shell,可以用来与上面的 Titan+Cassandra 通信。
cd rexster-console-2.3.0
bin/rexster-console.sh
我想从我的 python 程序中对 Titan Graph DB 进行编程。我为此使用了灯泡包。
from bulbs.titan import Graph
g = Graph()
vertex1 = g.vertices.get_or_create('dpid',dpid_str,{'state':'active','dpid':dpid_str,'type':'switch'}))
vertex2 = g.vertices.get_or_create('desc',desc,{'desc':desc,'port_id':port_id,'state':state,'port_state':port_state,'number':number,'type':'port'}))
从示例中,我了解如何在顶点之间创建边缘,如下所示
g.edges.create(vertex1,"out",vertex2)
但是假设我在我的程序中没有对顶点的引用。
我想使用它的键“dpid”检索顶点 1 并且我想使用它的键“desc”检索顶点 2
然后使用检索到的值创建边缘。我该怎么做?