Add PostgreSQL analytics dashboard prototype and realistic sample data

This commit is contained in:
maxwes08
2026-11-03 09:13:00 +01:00
commit 70b94f8672
38 changed files with 2873 additions and 0 deletions

24
mockups/database.py Normal file
View File

@@ -0,0 +1,24 @@
"""PostgreSQL connection settings for the development sample service."""
import json
import os
from pathlib import Path
import psycopg
from psycopg.rows import dict_row
ROOT = Path(__file__).resolve().parent.parent
def database_url():
configured = os.environ.get("DATABASE_URL")
if configured:
return configured
local = ROOT / ".local" / "database.json"
if local.exists():
return json.loads(local.read_text(encoding="utf-8-sig"))["url"]
raise RuntimeError("Database is not configured. Run mockups/setup-database.ps1 or set DATABASE_URL.")
def connect():
return psycopg.connect(database_url(), row_factory=dict_row, connect_timeout=5,
options="-c search_path=analytics,public -c timezone=UTC -c statement_timeout=15000")