_apply_notifylog_ddl.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. """P4-16 Apply ApprovalFlowNotifyLog DDL to shared dev DB."""
  3. import pymysql
  4. import re
  5. from pathlib import Path
  6. ddl_path = Path(r"d:/Projects/Ai-DOP/SourceCode/ZZYDOP/doc/migrations/2026-04-16_approval_flow_notify_log.sql")
  7. raw = ddl_path.read_text(encoding='utf-8')
  8. lines = [ln for ln in raw.splitlines() if not ln.strip().startswith('--')]
  9. clean = '\n'.join(lines)
  10. statements = [s.strip() for s in clean.split(';') if s.strip()]
  11. print(f"parsed {len(statements)} statements")
  12. conn = pymysql.connect(
  13. host='123.60.180.165', port=3306,
  14. user='aidopremote', password='1234567890aiDOP#',
  15. database='aidopdev', charset='utf8mb4', autocommit=True,
  16. )
  17. try:
  18. with conn.cursor() as cur:
  19. for st in statements:
  20. print(f"--> executing ({len(st)} chars): {st[:80]}...")
  21. cur.execute(st)
  22. print(" done")
  23. cur.execute("SHOW TABLES LIKE 'ApprovalFlowNotifyLog'")
  24. rows = cur.fetchall()
  25. print(f"Table check: {rows}")
  26. if rows:
  27. cur.execute("DESC ApprovalFlowNotifyLog")
  28. for r in cur.fetchall():
  29. print(r)
  30. finally:
  31. conn.close()