fix: Load .env file for dbt database credentials

dbt uses env_var() in profiles.yml to read POSTGRES_PASSWORD,
but subprocess.run() doesn't automatically load .env files.
Added python-dotenv to load credentials before dbt runs.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-18 12:10:46 -05:00
parent 451dc10a10
commit cf6e874961

View File

@@ -28,6 +28,11 @@ from datetime import date
from pathlib import Path
from typing import Any
from dotenv import load_dotenv
# Load .env file so dbt can access POSTGRES_* environment variables
load_dotenv()
# Add project root to path
PROJECT_ROOT = Path(__file__).parent.parent.parent
sys.path.insert(0, str(PROJECT_ROOT))