apply_1_0_263.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. """Apply UpdateScripts/1.0.263.sql to aidopdev."""
  2. from pathlib import Path
  3. from _db import get_conn
  4. SQL = Path(__file__).resolve().parents[4] / "server/Admin.NET.Web.Entry/UpdateScripts/1.0.263.sql"
  5. def main():
  6. body = "\n".join(ln for ln in SQL.read_text(encoding="utf-8").splitlines() if not ln.strip().startswith("--"))
  7. conn = get_conn()
  8. try:
  9. with conn.cursor() as cur:
  10. cur.execute(body)
  11. print("affected", cur.rowcount)
  12. cur.execute("SELECT COUNT(*) AS c FROM mdp_entity WHERE entity_code LIKE %s", ("%\\_API",))
  13. print("api_cnt", cur.fetchone()["c"])
  14. cur.execute(
  15. """
  16. SELECT COUNT(*) AS c FROM mdp_entity e
  17. WHERE e.entity_code NOT LIKE %s AND IFNULL(e.target_table_name,'')<>''
  18. AND NOT EXISTS (SELECT 1 FROM mdp_entity a WHERE a.entity_code=CONCAT(e.entity_code,'_API'))
  19. """,
  20. ("%\\_API",),
  21. )
  22. print("still_missing_with_stg", cur.fetchone()["c"])
  23. finally:
  24. conn.close()
  25. if __name__ == "__main__":
  26. main()