Support to copy project
This commit is contained in:
@@ -9,10 +9,13 @@ def have_project(name: str) -> bool:
|
||||
cur.execute(f"select * from pg_database where datname = '{name}'")
|
||||
return cur.rowcount > 0
|
||||
|
||||
def create_project(name: str) -> None:
|
||||
def copy_project(source: str, new: str) -> None:
|
||||
with pg.connect(conninfo="dbname=postgres", autocommit=True) as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(f"create database {name} with template = project")
|
||||
cur.execute(f"create database {new} with template = {source}")
|
||||
|
||||
def create_project(name: str) -> None:
|
||||
return copy_project('project', name)
|
||||
|
||||
def delete_project(name: str) -> None:
|
||||
with pg.connect(conninfo="dbname=postgres", autocommit=True) as conn:
|
||||
|
||||
Reference in New Issue
Block a user