| 123456789101112131415161718192021222324252627282930313233343536373839 |
- """Application settings.
- Configuration is read from the environment. For the MVP the two knobs are the
- database URL and the ``USE_FAKE_DATA`` flag.
- """
- from __future__ import annotations
- from functools import lru_cache
- from pydantic_settings import BaseSettings, SettingsConfigDict
- class Settings(BaseSettings):
- """Runtime settings, populated from environment variables.
- ``DATABASE_URL`` and ``USE_FAKE_DATA`` (case-insensitive) override defaults.
- """
- model_config = SettingsConfigDict(env_file=".env", extra="ignore")
- # Async SQLAlchemy URL. asyncpg driver is required for the async engine.
- database_url: str = "postgresql+asyncpg://hsdata:hsdata@localhost:5432/hsdata"
- # PostgreSQL schema holding the拼团 funnel tables. Real source is `ads`
- # (tables ads.ads_trd_group_funnel_*); set via connection search_path so the
- # schema-less ORM table names resolve there. Empty = leave default (public).
- db_schema: str = "ads"
- # When true, the funnel API serves a realistic in-memory snapshot instead of
- # querying Postgres. Default ON so `uvicorn app.main:app` works with zero
- # infrastructure. Set USE_FAKE_DATA=false to read the real wide table.
- use_fake_data: bool = True
- @lru_cache
- def get_settings() -> Settings:
- """Return a cached Settings instance."""
- return Settings()
|