SPA_TemperProductionOverview/_db.py
Erik 3d52e0b79e perf(db): serve presses + downtime-reason texts from the shared reference cache
press_settings.presses and settings.downtime_reasons are re-read on every 12s
overview poll; route them through the kernel cached_select() TTL cache so they
stop consuming a shared-pool checkout each poll. Part of the gateway
connection-pool-saturation fix (see fastAPI/agent_docs/db-pool-relief.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:06:40 +02:00

22 lines
985 B
Python

"""Kernel DB seam for the temper_overview page-module.
Mirrors ``modules/fastpress/press/_db.py``: the module reaches the database ONLY
through the gateway kernel's SELECT-only proxy, re-exported here so the coupling
to ``app.db`` lives in exactly one place. This page is read-only, so it needs
``run_select_query`` and nothing else (no ``transaction`` — it never writes).
The base scaffold's API (``api/routes.py``) returns SAMPLE data and does NOT import
this yet — wiring real SQL is the next step (see the TODO in ``api/routes.py``).
Keeping the seam here means that when the real query is added it imports::
from .._db import run_select_query
NOTE: no connection happens at import — SQLAlchemy's engine is lazy; the first
real connection opens only when a query actually executes.
"""
from __future__ import annotations
from app.db.mariadb import run_select_query, cached_select # noqa: F401 (kernel read proxies)
__all__ = ["run_select_query", "cached_select"]