This commit is contained in:
michaela.buzalkova
2026-04-24 06:00:26 +02:00
parent f8b7741f12
commit bb2973aa6d
+9 -3
View File
@@ -1,6 +1,12 @@
import socket
import sys
import pymysql
def _print(msg):
print(msg, file=sys.stdout, flush=True) if sys.stdout.encoding and sys.stdout.encoding.lower() in ("utf-8", "utf8") \
else print(msg.encode("utf-8", errors="replace").decode("ascii", errors="replace"), flush=True)
_LOCAL_HOSTS = {"lekar", "sestra", "lenovo"}
@@ -21,10 +27,10 @@ def connect_mysql(user="root", password="Vlado9674+", database="medevio",
for host in candidates:
try:
conn = pymysql.connect(host=host, **params)
print(f"[mysql_db] Připojeno přes {host} (hostname: {hostname})")
_print(f"[mysql_db] Pripojeno pres {host} (hostname: {hostname})")
return conn
except Exception as e:
print(f"[mysql_db] {host} selhal: {e}")
_print(f"[mysql_db] {host} selhal: {e}")
last_error = e
raise RuntimeError(f"MySQL nedostupné na žádné adrese. Poslední chyba: {last_error}")
raise RuntimeError(f"MySQL nedostupne na zadne adrese. Posledni chyba: {last_error}")