import time import pymysql print("Waiting for MySQL to boot...") retries = 30 while retries > 0: try: conn = pymysql.connect(host='127.0.0.1', port=3306, user='homelab', password='CHANGE_ME', database='homelab') conn.close() print("MySQL is ready!") break except Exception as e: print(f"Not ready yet, retrying in 2 seconds... ({e})") time.sleep(2) retries -= 1 if retries == 0: print("Failed to connect to MySQL after 60 seconds.") exit(1)