Support to list project
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from .project import have_project, create_project, delete_project
|
||||
from .project import list_project, have_project, create_project, delete_project
|
||||
from .project import is_project_open, get_project_open_count, open_project, close_project
|
||||
from .project import copy_project
|
||||
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import psycopg as pg
|
||||
from psycopg.rows import dict_row
|
||||
from .connection import g_conn_dict as conn
|
||||
|
||||
# no undo/redo
|
||||
|
||||
_project_open_count: dict[str, int] = {}
|
||||
|
||||
def list_project() -> list[str]:
|
||||
ps = []
|
||||
with pg.connect(conninfo="dbname=postgres host=127.0.0.1", autocommit=True) as conn:
|
||||
with conn.cursor(row_factory=dict_row) as cur:
|
||||
for p in cur.execute(f"select datname from pg_database where datname <> 'postgres' and datname <> 'template0' and datname <> 'template1' and datname <> 'project'"):
|
||||
ps.append(p['datname'])
|
||||
return ps
|
||||
|
||||
def have_project(name: str) -> bool:
|
||||
with pg.connect(conninfo="dbname=postgres host=127.0.0.1", autocommit=True) as conn:
|
||||
with conn.cursor() as cur:
|
||||
|
||||
@@ -116,6 +116,9 @@ def read_inp(name: str, inp: str) -> None:
|
||||
# operation
|
||||
############################################################
|
||||
|
||||
def list_project() -> list[str]:
|
||||
return api.list_project()
|
||||
|
||||
def get_current_operation(name: str) -> int:
|
||||
return api.get_current_operation(name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user