| 1 | import base64, json, re, urllib.request, urllib.error |
| 2 | text = open("/seed/99_dogrula.surql", encoding="utf-8").read() |
| 3 | lets = "\n".join(l.strip() for l in text.splitlines() if l.strip().startswith("LET ")) |
| 4 | blocks = re.split(r"\n(?=--\s*I\d+:)", text) |
| 5 | for b in blocks: |
| 6 | m = re.match(r"--\s*(I14):", b) |
| 7 | if not m: continue |
| 8 | body = "\n".join(l for l in b.splitlines() if not l.strip().startswith("--")).strip() |
| 9 | req = urllib.request.Request("http://hzk-surreal:8000/sql", data=(lets+"\n"+body).encode()) |
| 10 | req.add_header("Accept","application/json"); req.add_header("Content-Type","text/plain; charset=utf-8") |
| 11 | req.add_header("surreal-ns","hezarfen"); req.add_header("surreal-db","zeka") |
| 12 | req.add_header("Authorization","Basic "+base64.b64encode(b"root:root").decode()) |
| 13 | try: |
| 14 | urllib.request.urlopen(req, timeout=120) |
| 15 | except urllib.error.HTTPError as e: |
| 16 | print(e.read().decode("utf-8","replace")[:700]) |