# -*- coding: utf-8 -*- """检查 UAT 库 SysMenu 是否缺 业务动作日志/出站回写队列 菜单行;缺则按兄弟行模板补齐。""" from __future__ import annotations import sys import pymysql CONN = dict(host="123.60.180.165", port=3306, user="aidopremote", password="1234567890aiDOP#", database="aidopdev", charset="utf8mb4", connect_timeout=15) IDS = [1320990000400, 1320990000401, 1320990000402, 1320990000403, 1320990000404, 1320990000405, 1320990000406, 1320990000407, 1320990000408, 1320990000201] def main(): mode = sys.argv[1] if len(sys.argv) > 1 else "check" conn = pymysql.connect(**CONN) try: cur = conn.cursor() cur.execute("SHOW COLUMNS FROM SysMenu") cols = [r[0] for r in cur.fetchall()] print("COLUMNS", cols) marks = ",".join(str(i) for i in IDS) cur.execute(f"SELECT * FROM SysMenu WHERE Id IN ({marks})") rows = cur.fetchall() found = {r[0]: r for r in rows} print("FOUND", sorted(found)) missing = [i for i in IDS if i not in found] print("MISSING", missing) # 打印 sibling 行(数据任务日志 0405)全字段作为模板 tpl_id = 1320990000405 if tpl_id in found: print("TEMPLATE ROW (0405):") for c, v in zip(cols, found[tpl_id]): print(f" {c} = {v!r}") if mode == "fix" and missing: print("fix mode not implemented yet") finally: conn.close() if __name__ == "__main__": main()