Extract duplicated DATABASE_URL parsing to database.py

- Added ASYNCPG_DATABASE_URL constant in database.py
- Updated jobs.py to import from database module
- Updated worker.py to import from database module
- Removed duplicate URL parsing logic from both files
This commit is contained in:
counterweight 2025-12-21 23:16:29 +01:00
parent 405dfd526e
commit a8ad6e6384
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 11 additions and 18 deletions

View file

@ -7,6 +7,9 @@ DATABASE_URL = os.getenv(
"DATABASE_URL", "postgresql+asyncpg://postgres:postgres@localhost:5432/arbret"
)
# asyncpg needs postgresql:// instead of postgresql+asyncpg://
ASYNCPG_DATABASE_URL = DATABASE_URL.replace("postgresql+asyncpg://", "postgresql://")
engine = create_async_engine(DATABASE_URL)
async_session = async_sessionmaker(engine, expire_on_commit=False)