From 993238b8d7a4f39ca596a3000d6db8afd0137775 Mon Sep 17 00:00:00 2001 From: chenjiale Date: Tue, 9 Dec 2025 09:41:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(db):=20=E4=BF=AE=E5=A4=8D=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 model_cfg 表中的 id 字段更正为 model_id - 将 model_version 表中的 id 字段更正为 model_id - 确保模型查询逻辑使用正确的字段名 chore(docker): 更新 Debian 镜像源配置 - 替换基础镜像中的 APT 源为清华大学镜像站 - 在 builder 和 runtime 阶段均配置 bookworm 版本的清华源 - 优化源列表生成方式,提高可读性和维护性 - 保留 libodbc1 安装注释说明 --- Dockerfile | 16 +++++++++++----- PCA_Test.py | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 846906a..2e3d260 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,11 @@ # ====================== FROM python:3.10.16-slim AS builder -RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources \ - && sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources +# 使用清华源(Debian 12 Bookworm) +RUN printf "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n\ +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n\ +deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware\n" \ +> /etc/apt/sources.list RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -23,10 +26,13 @@ RUN pip install --no-cache-dir --prefix=/python_install \ # ====================== FROM python:3.10.16-slim -RUN sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources \ - && sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list.d/debian.sources +# 使用清华源(HTTPS) +RUN printf "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n\ +deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n\ +deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware\n" \ +> /etc/apt/sources.list -# ⭐ pyodbc 运行必须安装 libodbc1(提供 libodbc.so.2) +# pyodbc 必须安装 libodbc1(提供 libodbc.so.2) RUN apt-get update \ && apt-get install -y --no-install-recommends \ libodbc1 unixodbc \ diff --git a/PCA_Test.py b/PCA_Test.py index fde9b82..b60b0f8 100644 --- a/PCA_Test.py +++ b/PCA_Test.py @@ -189,13 +189,13 @@ class MySQL: self.conn.close() def get_model_by_ID(model_id, version="v-test"): ms = MySQL(host=config._SQL_IP, user="root", pwd="powerSIS#123", database="alert") - resList = ms.ExecQuery(f"SELECT Model_info FROM model_cfg where id={model_id}") + resList = ms.ExecQuery(f"SELECT Model_info FROM model_cfg where model_id={model_id}") return json.loads(resList[0][0]) def get_model_by_id_and_version(model_id, version): ms = MySQL(host=config._SQL_IP, user="root", pwd="powerSIS#123", database="alert") - resList = ms.ExecQuery(f"SELECT Model_info FROM model_version where id={model_id} and version='{version}'") + resList = ms.ExecQuery(f"SELECT Model_info FROM model_version where model_id={model_id} and version='{version}'") return json.loads(resList[0][0]) def pca(model, Data_origin):