commit
0ee8899f68
2 changed files with 16 additions and 16 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."""
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ services:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 50051:50051
|
- 50051:50051
|
||||||
- 5678:5678
|
- 5678:5678
|
||||||
- 5432:5432
|
# - 5432:5432
|
||||||
depends_on:
|
depends_on:
|
||||||
# - postgres
|
- postgres
|
||||||
- neo4j
|
- neo4j
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
|
|
@ -43,18 +43,18 @@ services:
|
||||||
cpus: "4.0"
|
cpus: "4.0"
|
||||||
memory: 8GB
|
memory: 8GB
|
||||||
|
|
||||||
# postgres:
|
postgres:
|
||||||
# image: postgres
|
image: postgres
|
||||||
# container_name: postgres
|
container_name: postgres
|
||||||
# environment:
|
environment:
|
||||||
# - POSTGRES_HOST_AUTH_METHOD=trust
|
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||||
# - POSTGRES_USER=bla
|
- POSTGRES_USER=bla
|
||||||
# - POSTGRES_PASSWORD=bla
|
- POSTGRES_PASSWORD=bla
|
||||||
# - POSTGRES_DB=bubu
|
- POSTGRES_DB=bubu
|
||||||
# networks:
|
networks:
|
||||||
# - cognee_backend
|
- cognee_backend
|
||||||
# ports:
|
ports:
|
||||||
# - "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
cognee_backend:
|
cognee_backend:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue