From cdb6344013e71ee2096fec395f313344dd7aa945 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Thu, 1 Jan 2026 15:43:44 +0100 Subject: [PATCH] feat: add PostgreSQL database configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD settings - Add database_url property for connection string construction - Database: core_api on shared postgres instance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .env.example | 8 ++++++++ pyproject.toml | 2 +- src/config.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 4e03065..ef3ba42 100644 --- a/.env.example +++ b/.env.example @@ -48,6 +48,14 @@ OLLAMA_BASE_URL=http://localhost:11434 # SearXNG (self-hosted search) SEARXNG_URL=http://localhost:8080 +# ============================================================================= +# Database (PostgreSQL) +# ============================================================================= + +POSTGRES_HOST=localhost:5432 +POSTGRES_USER=core_api +POSTGRES_PASSWORD=your-password + # ============================================================================= # Vector Database # ============================================================================= diff --git a/pyproject.toml b/pyproject.toml index 25f8526..329ce7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "core-api" -version = "1.3.3" +version = "1.3.4" description = "Core Code API - Infrastructure management and tools API" readme = "README.md" requires-python = ">=3.12" diff --git a/src/config.py b/src/config.py index 0a96c29..1aa219f 100644 --- a/src/config.py +++ b/src/config.py @@ -106,6 +106,17 @@ class Settings(BaseSettings): homeassistant_token: str # Required - set HOMEASSISTANT_TOKEN in .env homeassistant_timeout: int = 30 + # PostgreSQL Database + postgres_host: str # Required - set POSTGRES_HOST in .env (e.g., localhost:5432) + postgres_user: str = "core_api" + postgres_password: str # Required - set POSTGRES_PASSWORD in .env + postgres_database: str = "core_api" + + @property + def database_url(self) -> str: + """Construct database URL from components""" + return f"postgresql://{self.postgres_user}:{self.postgres_password}@{self.postgres_host}/{self.postgres_database}" + # OIDC Authentication (Authentik) oidc_enabled: bool = False # Set to True to require authentication oidc_issuer: str = "https://auth.schweitz.net/application/o/core-api/"