def delete_connection(nid1,nid2): mydb.open() p1 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid1], one = True) p2 = mydb.query_db('SELECT * FROM node WHERE nid = ?', [nid2], one = True) mydb.delete_db('delete from edge where _from = ? and _to = ?',[p1['pid'], p2['pid']]) mydb.delete_db('delete from edge where _from = ? and _to = ?',[p2['pid'], p1['pid']]) mydb.close_db() pass
def delete_pattern(pattern_id): mydb.open() mydb.delete_db('delete from edge where _from = ? or _to = ?',[pattern_id, pattern_id]) mydb.delete_db('delete from pattern where pid=?', [pattern_id]) mydb.delete_db('delete from node where pid=? and node_index = 1', [pattern_id]) mydb.close_db() return True
def delete_pattern(pattern_id): mydb.open() nodes = mydb.query_db('SELECT * FROM node WHERE pid = ?',[pattern_id]) if len(nodes) > 1: return False prohibited_node = [] results = mydb.query_db('SELECT * FROM pattern') for p in results: pid = p['pid'] re1 = mydb.query_db('SELECT * FROM edge WHERE _from = ?',[pid]) re2 = mydb.query_db('SELECT * FROM edge WHERE _to = ?',[pid]) if len(re1)+len(re2) == 1: if len(re1) == 1: pro = re1[0]['_to'] else: pro = re2[0]['_from'] prohibited_node.append(pro) print prohibited_node if pid in prohibited_node: mydb.close_db() return False else: mydb.delete_db('delete from edge where _from = ? or _to = ?',[pattern_id, pattern_id]) mydb.delete_db('delete from pattern where pid=?', [pattern_id]) mydb.delete_db('delete from node where pid=? and node_index = 1', [pattern_id]) mydb.close_db() return True
def delete_domain(pid, did): mydb.open() d_pattern = mydb.query_db('SELECT * FROM pattern WHERE did = ? and isDomain = 1', [did], one = True) mydb.delete_db('delete from edge where _from = ? or _to = ?',[d_pattern['pid'], d_pattern['pid']]) mydb.delete_db('delete from domain where did=?', [did]) mydb.delete_db('delete from pattern where pid=?', [d_pattern['pid']]) mydb.delete_db('delete from node where pid=?', [d_pattern['pid']]) mydb.delete_db('delete from pattern where pid=?', [pid]) mydb.delete_db('delete from node where pid=?', [pid]) mydb.close_db() return True
def delete_node(nids): mydb.open() for n in nids: mydb.delete_db('delete from node where nid = ?',[n]) mydb.close_db()
def delete_user(username): mydb.open() mydb.delete_db('delete from account where username = ? ',[username]) mydb.close_db()