Files
eco_analyse/data/pg_sync_cache/README.md
T

9 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PostgreSQL (`120.0.0.1:5432`) 離線同步快取鏡像目錄 (`data/pg_sync_cache/`)
本目錄專門存放從遠端資料庫主機 `120.0.0.1`(PostgreSQL `eco_analyse_dw`)透過 Airflow `sync_local_data_cache` 任務匯出之 **唯讀離線鏡像檔案**(CSV / Parquet)。
## 設計分工說明(為何不把 Airflow DAG 或 Postgres 程式放進 `data/`)
1. **資料庫本體與執行碼分離**:PostgreSQL 主機執行於獨立資料庫服務(`120.0.0.1:5432`);連線驅動與倉儲契約封裝於 `src/infra/postgres_warehouse.py`;Airflow DAG 與 dbt SQL 模型置於 `src/orchestration/`。
2. **離線容錯與單元測試(Offline Fallback)**:當開發環境離線、主機 `120.0.0.1` 停機維護,或執行 `src/test_bdd_scenarios.py` 離線單元測試時,`PostgresWarehouseConnector` 會自動降級讀取本目錄(以及 `data/features_aligned/`)之本地鏡像,確保研究運算不中斷且測試 100% 可重現。
3. **本體種子表**:供應鏈「產品工法 -> 料工費 -> 國別廠房風險」靜態設定檔統一置於 `data/supply_chain_ontology/`,同時供應 `dbt seed` 匯入 `120.0.0.1` 與離線轉接器讀取。