Fixes to database manager
This commit is contained in:
parent
a7e83385da
commit
77d2e1b9ef
1 changed files with 2 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ class DatabaseManager:
|
||||||
"""Manages database creation, deletion, and table initialization."""
|
"""Manages database creation, deletion, and table initialization."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the Database Url with a given configuration."""
|
"""Initialize the Database Url with a given configuration."""
|
||||||
self.engine = create_async_engine(get_sqlalchemy_database_url("sqlite"), echo = True)
|
self.engine = create_async_engine(get_sqlalchemy_database_url(globalConfig.db_type), echo = True)
|
||||||
self.db_type = globalConfig.db_type
|
self.db_type = globalConfig.db_type
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
|
|
@ -37,7 +37,7 @@ class DatabaseManager:
|
||||||
query = text(f"SELECT 1 FROM pg_database WHERE datname='{db_name}'")
|
query = text(f"SELECT 1 FROM pg_database WHERE datname='{db_name}'")
|
||||||
async with self.get_connection() as connection:
|
async with self.get_connection() as connection:
|
||||||
result = await connection.execute(query)
|
result = await connection.execute(query)
|
||||||
return await result.fetchone() is not None
|
return result.fetchone() is not None
|
||||||
|
|
||||||
async def create_database(self, db_name):
|
async def create_database(self, db_name):
|
||||||
"""Create a new database."""
|
"""Create a new database."""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue