diff --git a/api/s0_base.py b/api/s0_base.py index bedcd28..c966e66 100644 --- a/api/s0_base.py +++ b/api/s0_base.py @@ -179,3 +179,15 @@ def delete_link(name: str, link_type: str, id: str, table_sql: str, table_undo_s change = ChangeSet() change.delete(link_type, id) 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