This commit is contained in:
michaela.buzalkova
2025-10-07 09:06:43 +02:00
parent 70f54d1da5
commit 746963157a
2 changed files with 9 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ K_DATU = date.today().isoformat() # YYYY-MM-DD
ODBORNOSTI = ["001"] # VPL (adult GP) ODBORNOSTI = ["001"] # VPL (adult GP)
# MySQL # MySQL
if socket.gethostname().strip() in ("NTBVBHP470G10","Z230"): if socket.gethostname().strip() == "NTBVBHP470G10":
MYSQL_CFG = dict( MYSQL_CFG = dict(
host="192.168.1.76", host="192.168.1.76",
port=3307, port=3307,
@@ -175,13 +175,13 @@ ON DUPLICATE KEY UPDATE
for p in payloads: for p in payloads:
pprint(p) pprint(p)
connsql = get_mysql_connection() conn = pymysql.connect(**MYSQL_CFG)
try: try:
with connsql.cursor() as cur: with conn.cursor() as cur:
cur.executemany(sql, payloads) cur.executemany(sql, payloads)
connsql.commit() conn.commit()
finally: finally:
connsql.close() conn.close()
print(f"\nUpserted rows: {len(payloads)}") print(f"\nUpserted rows: {len(payloads)}")
return len(payloads) return len(payloads)
@@ -216,7 +216,7 @@ def main():
con = get_medicus_connection() con = get_medicus_connection()
cur = con.cursor() cur = con.cursor()
cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '8'") cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '9'")
# cur.execute("select first 2 rodcis, prijmeni, jmeno from kar where rodcis starting with '0'") # cur.execute("select first 2 rodcis, prijmeni, jmeno from kar where rodcis starting with '0'")
# Vytvor seznam rodnych cisel, která už máme # Vytvor seznam rodnych cisel, která už máme
@@ -245,18 +245,17 @@ def main():
"Content-Type": "text/xml; charset=utf-8", "Content-Type": "text/xml; charset=utf-8",
"SOAPAction": "process", # Oracle composite usually expects this "SOAPAction": "process", # Oracle composite usually expects this
} }
print(envelope)
# Call service # Call service
resp = session.post(ENDPOINT, data=envelope.encode("utf-8"), resp = session.post(ENDPOINT, data=envelope.encode("utf-8"),
headers=headers, timeout=30, verify=VERIFY) headers=headers, timeout=30, verify=VERIFY)
print("HTTP:", resp.status_code) print("HTTP:", resp.status_code)
# (Optional) Uncomment to see raw XML # (Optional) Uncomment to see raw XML
print(resp.text) # print(resp.text)
# Parse and save # Parse and save
rows, stav = parse_registrace(resp.text) rows, stav = parse_registrace(resp.text)
print(rows,stav)
upsert_rows(RC, K_DATU, rows, stav, resp.text) upsert_rows(RC, K_DATU, rows, stav, resp.text)
time.sleep(random.uniform(1, 5)) time.sleep(random.uniform(1, 5))

View File

@@ -252,7 +252,7 @@ def main():
con = get_medicus_connection() con = get_medicus_connection()
cur = con.cursor() cur = con.cursor()
cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '6'") cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '1'")
# cur.execute("select first 2 rodcis, prijmeni, jmeno from kar where rodcis starting with '0'") # cur.execute("select first 2 rodcis, prijmeni, jmeno from kar where rodcis starting with '0'")
# Vytvor seznam rodnych cisel, která už máme # Vytvor seznam rodnych cisel, která už máme