feat: 过滤更新参数,只保留 video 表中存在的列

This commit is contained in:
晓丰 2025-05-23 00:07:33 +08:00
parent c46f4d9b83
commit da374a7ed0

6
DB.py
View File

@ -602,13 +602,15 @@ class DBSA:
params = dict(stats) params = dict(stats)
params["updatetime"] = int(time.time()) params["updatetime"] = int(time.time())
# 过滤只保留 video 表中存在的列
valid_cols = set(video.c.keys())
filtered_params = {k: v for k, v in params.items() if k in valid_cols}
# 使用 Core Table 的 update() 方法
stmt = ( stmt = (
video video
.update() .update()
.where(video.c.v_xid == v_xid, video.c.rn == rn) .where(video.c.v_xid == v_xid, video.c.rn == rn)
.values(**params) .values(**filtered_params)
) )
with _engine.begin() as conn: with _engine.begin() as conn:
result = conn.execute(stmt) result = conn.execute(stmt)