_check_uat_menus.py 1.5 KB

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