feat: persist ingest flow in postgres
Tests / test (push) Failing after 1m16s
Tests / lint (push) Failing after 34s

This commit is contained in:
Xiaoxia AI
2026-06-15 19:34:47 +08:00
parent 7f416700de
commit 99e72cdcba
16 changed files with 161 additions and 78 deletions
@@ -0,0 +1,46 @@
from __future__ import annotations
from sqlalchemy import create_engine
from sqlalchemy.orm import Session, sessionmaker
from packages.adapters.sqlalchemy_impl.models import Base
def build_engine(
database_url: str,
*,
pool_size: int = 20,
max_overflow: int = 40,
pool_timeout: int = 30,
pool_recycle: int = 3600,
):
return create_engine(
database_url,
pool_size=pool_size,
max_overflow=max_overflow,
pool_timeout=pool_timeout,
pool_recycle=pool_recycle,
)
def build_session_factory(
database_url: str,
*,
pool_size: int = 20,
max_overflow: int = 40,
pool_timeout: int = 30,
pool_recycle: int = 3600,
):
engine = build_engine(
database_url,
pool_size=pool_size,
max_overflow=max_overflow,
pool_timeout=pool_timeout,
pool_recycle=pool_recycle,
)
session_factory = sessionmaker(autocommit=False, autoflush=False, bind=engine)
return engine, session_factory
def initialize_database(engine) -> None:
Base.metadata.create_all(bind=engine)