Some checks failed
build-and-deploy / build (push) Failing after 18s
- Add app/config.py (12-factor, env-driven: DB/NATS/MinIO, URL-encoded pw) - Route database/ingestor/sources/alembic through config; kill hardcoded svc.cluster.local hostnames - Drop unused redis dependency - Add docker-compose.yml (timescaledb-postgis pg13 arm64 + optional nats) - Add .env.example, .dockerignore, .forgejo/workflows/build.yml (arm64 build+SSH deploy)
20 lines
724 B
Python
20 lines
724 B
Python
from sqlalchemy import MetaData, event, text
|
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
|
|
from config import DATABASE_URL
|
|
|
|
engine = create_async_engine(
|
|
DATABASE_URL, echo=False, pool_size=5, max_overflow=10, pool_recycle=300
|
|
)
|
|
async_session = async_sessionmaker(
|
|
engine, class_=AsyncSession, expire_on_commit=False
|
|
)
|
|
metadata = MetaData()
|
|
|
|
|
|
async def init_extensions():
|
|
"""Initialize PostGIS and TimescaleDB extensions on first connection."""
|
|
async with engine.connect() as conn:
|
|
await conn.execute(text("CREATE EXTENSION IF NOT EXISTS postgis"))
|
|
await conn.execute(text("CREATE EXTENSION IF NOT EXISTS timescaledb"))
|
|
await conn.commit()
|