Beispiel #1
0
def createNode(level_id, parent_id, parentlevel_id, type_id, attributes):
    """Create node in db.

    Uses Node class for the node creation and coding for the node type
    attributes store.

    TODO store any attributes len.

    @param level id
    @param parent id
    @param parentlevel id
    @param type id
    @param attributes tuple of node attributes
    """
    N = class_node.node(level_id, parent_id, parentlevel_id, type_id)
    node_id = N.store(db)

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

    st = ("INSERT INTO gn_" + tag_level + "_nodes_type_" + tag_type +  
          " VALUES(" + str(node_id) + ", '" + attributes[0] + "');")
    db.query(st)
Beispiel #2
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
################################################################################

from model import class_edge 
from model import class_node
from model.db_connection import db

##
# 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)