This commit is contained in:
wqy
2022-09-03 11:08:05 +08:00
parent c3dcf70a04
commit 8fe2eebe03
3 changed files with 33 additions and 0 deletions

View File

@@ -53,3 +53,23 @@ def is_curve(name: str, id: str) -> bool:
def is_pattern(name: str, id: str) -> bool:
return _get_from(name, id, _PATTERN) != None
def _get_all(name: str, base_type: str) -> list[str]:
ids : list[str] = []
with conn[name].cursor(row_factory=dict_row) as cur:
cur.execute(f"select id from {base_type} order by id")
for record in cur:
ids.append(record['id'])
return ids
def get_nodes(name: str) -> list[str]:
return _get_all(name, _NODE)
def get_links(name: str) -> list[str]:
return _get_all(name, _LINK)
def get_curves(name: str) -> list[str]:
return _get_all(name, _CURVE)
def get_patterns(name: str) -> list[str]:
return _get_all(name, _PATTERN)