Get link of node
This commit is contained in:
@@ -179,3 +179,15 @@ def delete_link(name: str, link_type: str, id: str, table_sql: str, table_undo_s
|
|||||||
change = ChangeSet()
|
change = ChangeSet()
|
||||||
change.delete(link_type, id)
|
change.delete(link_type, id)
|
||||||
return change
|
return change
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_links(name: str, id: str) -> list[str]:
|
||||||
|
with conn[name].cursor(row_factory=dict_row) as cur:
|
||||||
|
links: list[str] = []
|
||||||
|
for p in cur.execute(f"select id from pipes where node1 = '{id}' or node2 = '{id}'").fetchall():
|
||||||
|
links.append(p['id'])
|
||||||
|
for p in cur.execute(f"select id from pumps where node1 = '{id}' or node2 = '{id}'").fetchall():
|
||||||
|
links.append(p['id'])
|
||||||
|
for p in cur.execute(f"select id from valves where node1 = '{id}' or node2 = '{id}'").fetchall():
|
||||||
|
links.append(p['id'])
|
||||||
|
return links
|
||||||
|
|||||||
Reference in New Issue
Block a user