Get link of node

This commit is contained in:
wqy
2022-09-22 21:05:30 +08:00
parent 28fa751fbf
commit 345ce9a98d

View File

@@ -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