Files
ZQYY.FQ-ETL/scripts/README.md

39 lines
1.6 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.
# scripts/ — 运维与工具脚本
## 子目录
| 目录 | 用途 | 典型场景 |
|------|------|----------|
| `audit/` | 仓库审计(文件清单、调用流、文档对齐分析) | `python -m scripts.audit.run_audit` |
| `check/` | 数据检查ODS 缺口、内容哈希、完整性校验) | `python -m scripts.check.check_data_integrity` |
| `db_admin/` | 数据库管理Excel 导入 DWS 支出/回款/提成) | `python scripts/db_admin/import_dws_excel.py --type expense` |
| `export/` | 数据导出(指数、团购、亲密度、会员明细等) | `python scripts/export/export_index_tables.py` |
| `rebuild/` | 数据重建(全量 ODS→DWD 重建) | `python scripts/rebuild/rebuild_db_and_run_ods_to_dwd.py` |
| `repair/` | 数据修复回填、去重、hash 修复、维度修复) | `python scripts/repair/dedupe_ods_snapshots.py` |
## 根目录脚本
- `run_update.py` — 一键增量更新ODS → DWD → DWS适合 cron/计划任务调用
- `run_ods.bat` — Windows 批处理ODS 建表 + 灌入示例 JSON
## 运行方式
所有脚本在项目根目录(`C:\ZQYY\FQ-ETL`)执行:
```bash
# 审计报告生成
python -m scripts.audit.run_audit
# 一键增量更新
python scripts/run_update.py
# 数据完整性检查(需要数据库连接)
python -m scripts.check.check_data_integrity --window-start "2025-01-01" --window-end "2025-02-01"
```
## 注意事项
- 所有脚本依赖 `.env` 中的 `PG_DSN` 配置(或环境变量)
- `rebuild/` 下的脚本会重建 Schema生产环境慎用
- `repair/` 下的脚本会修改数据,建议先 `--dry-run`(如支持)