| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- """Apply UpdateScripts/1.0.264.sql to aidopdev."""
- from __future__ import annotations
- import pathlib
- import sys
- from _db import get_conn
- ROOT = pathlib.Path(__file__).resolve().parents[4]
- SQL = ROOT / "server" / "Admin.NET.Web.Entry" / "UpdateScripts" / "1.0.264.sql"
- def main() -> int:
- text = SQL.read_text(encoding="utf-8")
- parts = []
- buf = []
- for line in text.splitlines():
- if line.strip().startswith("--"):
- continue
- buf.append(line)
- if line.rstrip().endswith(";"):
- stmt = "\n".join(buf).strip().rstrip(";").strip()
- if stmt:
- parts.append(stmt)
- buf = []
- if buf:
- stmt = "\n".join(buf).strip().rstrip(";").strip()
- if stmt:
- parts.append(stmt)
- conn = get_conn()
- try:
- with conn.cursor() as cur:
- for i, stmt in enumerate(parts, 1):
- cur.execute(stmt)
- print(f"OK {i}/{len(parts)}")
- cur.execute(
- "SELECT entity_code FROM mdp_entity WHERE entity_code IN (%s,%s)",
- ("S6_REPORT", "S6_REPORT_API"),
- )
- print("entities", cur.fetchall())
- finally:
- conn.close()
- return 0
- if __name__ == "__main__":
- raise SystemExit(main())
|