diff --git a/Controller/mysql_connect.py b/Controller/mysql_connect.py index 77b19b9..2633891 100644 --- a/Controller/mysql_connect.py +++ b/Controller/mysql_connect.py @@ -1,9 +1,20 @@ import mysql.connector import mysql.connector.locales.eng.client_error from sshtunnel import SSHTunnelForwarder +import os + +def ping(host): + # Führe den Ping-Befehl aus und erfasse die Ausgabe + result = os.system("ping -c 1 " + host) + return result + +if ping("172.17.1.21") == 0: + hostname = "172.17.1.21, 2223" +else: + hostname = "forward.stines.de, 2223" server = SSHTunnelForwarder( - ('forward.stines.de', 2223), + (hostname), ssh_username="root", ssh_password="adm.3dfx12", remote_bind_address=('127.0.0.1', 3306)