Fix: Read DATABASE_URL directly from .env (avoid import issues)
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
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:
@ -87,9 +87,20 @@ class ZoneSyncResult:
|
|||||||
|
|
||||||
async def get_db_session():
|
async def get_db_session():
|
||||||
"""Create async database 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)
|
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
||||||
return async_session()
|
return async_session()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user