【发布时间】:2014-06-16 01:42:38
【问题描述】:
我正在使用 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”检索vertex2
然后使用检索到的值创建边缘。我该怎么做?
【问题讨论】: