【发布时间】:2025-12-18 05:25:01
【问题描述】:
上下文:我有一个 ETL 流程设置,用于使用 Python 脚本填充数据仓库中的表。该脚本通过 sqlalchemy 执行 truncate 语句以清空每个表,然后使用 pandas .to_sql 方法从数据框中加载新的源数据。见下sn-p:
engine.execute(sa_text(f'''TRUNCATE TABLE {schema}.{table}''').execution_options(autocommit=True))
df.to_sql(table, con=engine, schema=schema, if_exists='append', index=False, chunksize=chunksize,
method=method)
问题:奇怪的是,每个表的 SQL Server sys.tables modify_date 列并未捕获反映最新 modify_date 的表更改。有人可以向我解释为什么会这样,以及如何修改我的 Python 代码和/或 SQL Server 设置以准确捕获 sys.tables 中的更改吗?
【问题讨论】:
标签: sql-server pandas sqlalchemy truncate pandas-to-sql