Ejemplo n.º 1
0
def connectNodes(level_id, idnA, idnB, parent_id, parentlevel_id, type_id, attributes):
    """Create edge in db.

    Uses Edge class for the edge creation and coding for the edge type
    attributes store.

    TODO store any attributes len.

    @param level id
    @param node A id
    @param node B id
    @param parent id
    @param parentlevel id
    @param type id
    @param attributes tuple of edge attributes
    """
    E = class_edge.edge(level_id, idnA, idnB, parent_id, parentlevel_id, type_id)
    edge_id = E.store(db)

    tag_level = genet_global.tagName(level_id)
    tag_type =  genet_global.tagName(type_id)

    st = ("INSERT INTO gn_" + tag_level + "_edges_type_" + tag_type +  
          " VALUES(" + str(edge_id) + ", '" + attributes[0] + "');")
    db.query(st)
Ejemplo n.º 2
0
##
# Insert data.
#
N001 = class_node.node(1, 0, 0, 2)
print N001.store(db)

N002 = class_node.node(1, 0, 0, 2)
print N002.store(db)

N003 = class_node.node(1, 0, 0, 2)
print N003.store(db)
N003.idtype = 4
print N003.store(db)

E001 = class_edge.edge(1, N001.id, N002.id, 0, 0, 3)
print E001.store(db)

E002 = class_edge.edge(1, N002.id, N003.id, 0, 0, 3)
print E002.store(db)

E003 = class_edge.edge(1, N003.id, N001.id, 0, 0, 3)
print E003.store(db)

E004 = class_edge.edge(1, N001.id, N002.id, 0, 0, 3)
print E004.store(db)

for r in db.query("SELECT * FROM gn_01_nodes").dictresult():
    print 'id %(id)s, idtype %(idtype)s' % r

for r in db.query("SELECT * FROM gn_01_edges").dictresult():