From d96668424fffafa4d009d2b8425c66a29afc54ad Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Wed, 17 Dec 2025 10:07:53 +0100 Subject: [PATCH] Fix: Read DATABASE_URL directly from .env (avoid import issues) --- backend/scripts/sync_all_zones.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/scripts/sync_all_zones.py b/backend/scripts/sync_all_zones.py index 1f6280a..50b857f 100644 --- a/backend/scripts/sync_all_zones.py +++ b/backend/scripts/sync_all_zones.py @@ -87,9 +87,20 @@ class ZoneSyncResult: async def get_db_session(): """Create async database session""" - from app.config import settings + # Read DATABASE_URL from .env file directly (avoids import issues) + env_file = Path("/home/user/pounce/backend/.env") + db_url = "sqlite+aiosqlite:///./domainwatch.db" # default - engine = create_async_engine(settings.database_url.replace("sqlite://", "sqlite+aiosqlite://")) + if env_file.exists(): + for line in env_file.read_text().splitlines(): + if line.startswith("DATABASE_URL="): + url = line.split("=", 1)[1].strip() + # Convert to async SQLite URL + if "sqlite://" in url: + db_url = url.replace("sqlite://", "sqlite+aiosqlite://") + break + + engine = create_async_engine(db_url) async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) return async_session()