添加 ETL 脚本:导出并丰富 loops 数据(交互式密码输入)
- 提取 SOURCE 库中 loops 表中 type 为 '0'/'1' 的行,联表补全酒店与房型名称,创建目标 schema/table 并写入到 TARGET 库。 - 使用 SQLAlchemy + pandas 实现;支持通过环境变量配置连接信息,包含用于创建目标表的 create_target_table 函数和用于构建连接 URL 的 build_url 函数。 - 脚本会在目标库创建 schema(若不存在)并重建目标表。 - 依赖: pandas, sqlalchemy, psycopg2。
This commit is contained in:
@@ -5,6 +5,7 @@ import pandas as pd
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
|
||||
|
||||
def build_url(prefix: str) -> str:
|
||||
user = os.getenv(f"{prefix}_PG_USER", "log_admin")
|
||||
password = os.getenv(f"{prefix}_PG_PASSWORD")
|
||||
|
||||
Reference in New Issue
Block a user