feat: Introduce an asynchronous PostgreSQL connection manager with schema migration for multi-server support and granular configuration.
This commit is contained in:
+6
-1
@@ -9,7 +9,12 @@ services:
|
|||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
environment:
|
environment:
|
||||||
- BOT_TOKEN=${BOT_TOKEN}
|
- BOT_TOKEN=${BOT_TOKEN}
|
||||||
- POSTGRES_URL=${POSTGRES_URL:-postgresql+asyncpg://virtus:password@db:5432/virtus_bot}
|
- POSTGRES_URL=${POSTGRES_URL}
|
||||||
|
- POSTGRES_HOST=${POSTGRES_HOST:-db}
|
||||||
|
- POSTGRES_PORT=${POSTGRES_PORT:-5432}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-virtus}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-virtus_bot}
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
command: uv run python main.py
|
command: uv run python main.py
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class PostgresConnection:
|
|||||||
raw_url = f"postgresql+asyncpg://{auth}{host}:{port}/{database}"
|
raw_url = f"postgresql+asyncpg://{auth}{host}:{port}/{database}"
|
||||||
|
|
||||||
url = _normalize_asyncpg_url(raw_url)
|
url = _normalize_asyncpg_url(raw_url)
|
||||||
|
print(f"🔌 Connecting to database at: {url.split('@')[-1] if '@' in url else url}")
|
||||||
|
|
||||||
self.engine: AsyncEngine = create_async_engine(
|
self.engine: AsyncEngine = create_async_engine(
|
||||||
url,
|
url,
|
||||||
|
|||||||
Reference in New Issue
Block a user