From 22eeb85765c3e3febfc3806858db4b7fdd9eec5c Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Wed, 17 Dec 2025 11:52:44 +0100 Subject: [PATCH] Fix: Use get_settings() instead of settings (correct import) --- backend/scripts/sync_all_zones.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/scripts/sync_all_zones.py b/backend/scripts/sync_all_zones.py index 50b857f..633626d 100644 --- a/backend/scripts/sync_all_zones.py +++ b/backend/scripts/sync_all_zones.py @@ -87,18 +87,14 @@ class ZoneSyncResult: async def get_db_session(): """Create async database session""" - # 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 + from app.config import get_settings - 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 + settings = get_settings() + db_url = settings.database_url + + # Ensure we use async SQLite driver + if "sqlite://" in db_url and "aiosqlite" not in db_url: + db_url = db_url.replace("sqlite://", "sqlite+aiosqlite://") engine = create_async_engine(db_url) async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) @@ -625,4 +621,4 @@ async def main(): if __name__ == "__main__": exit_code = asyncio.run(main()) - sys.exit(exit_code) + sys.exit(exit_code) \ No newline at end of file