Fix: Use get_settings() instead of settings (correct import)
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled

This commit is contained in:
2025-12-17 11:52:44 +01:00
parent d96668424f
commit 22eeb85765

View File

@ -87,18 +87,14 @@ class ZoneSyncResult:
async def get_db_session(): async def get_db_session():
"""Create async database session""" """Create async database session"""
# Read DATABASE_URL from .env file directly (avoids import issues) from app.config import get_settings
env_file = Path("/home/user/pounce/backend/.env")
db_url = "sqlite+aiosqlite:///./domainwatch.db" # default
if env_file.exists(): settings = get_settings()
for line in env_file.read_text().splitlines(): db_url = settings.database_url
if line.startswith("DATABASE_URL="):
url = line.split("=", 1)[1].strip() # Ensure we use async SQLite driver
# Convert to async SQLite URL if "sqlite://" in db_url and "aiosqlite" not in db_url:
if "sqlite://" in url: db_url = db_url.replace("sqlite://", "sqlite+aiosqlite://")
db_url = url.replace("sqlite://", "sqlite+aiosqlite://")
break
engine = create_async_engine(db_url) engine = create_async_engine(db_url)
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
@ -625,4 +621,4 @@ async def main():
if __name__ == "__main__": if __name__ == "__main__":
exit_code = asyncio.run(main()) exit_code = asyncio.run(main())
sys.exit(exit_code) sys.exit(exit_code)