Replace hardcoded DB credentials with environment-driven configuration.
Centralize DB settings in ingestion config, remove embedded secrets from ingestion helpers, and add an idempotent PostgreSQL bootstrap script to create role/database and apply schema safely. Made-with: Cursor
This commit is contained in:
31
src/data/ingestion/config/settings.py
Normal file
31
src/data/ingestion/config/settings.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
|
||||
|
||||
def _get_env_int(name: str, default: int) -> int:
|
||||
raw = os.getenv(name)
|
||||
if raw is None:
|
||||
return default
|
||||
try:
|
||||
return int(raw)
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Environment variable {name} must be an integer, got '{raw}'") from exc
|
||||
|
||||
|
||||
def _get_env_list(name: str, default: list[str]) -> list[str]:
|
||||
raw = os.getenv(name)
|
||||
if not raw:
|
||||
return default
|
||||
return [x.strip() for x in raw.split(",") if x.strip()]
|
||||
|
||||
|
||||
DB_CONFIG = {
|
||||
"host": os.getenv("DB_HOST", "localhost"),
|
||||
"port": _get_env_int("DB_PORT", 5432),
|
||||
"database": os.getenv("DB_NAME", "options_db"),
|
||||
"user": os.getenv("DB_USER", "quant_user"),
|
||||
"password": os.getenv("DB_PASSWORD", ""),
|
||||
}
|
||||
|
||||
PIPELINE_CONFIG = {
|
||||
"symbols": _get_env_list("PIPELINE_SYMBOLS", ["SPY"]),
|
||||
}
|
||||
Reference in New Issue
Block a user