import mysql.connector def get_connection_details(): details = {} with open('setting.txt', 'r') as f: for line in f: key, value = line.strip().split(':', 1) details[key.strip()] = value.strip() return details try: config = get_connection_details() conn = mysql.connector.connect( host=config.get('Host'), port=config.get('Port'), user=config.get('Username'), password=config.get('Password'), database=config.get('Database') ) print("Connection successful!") conn.close() except ImportError: print("Error: mysql-connector-python is not installed. Please install it using: pip install mysql-connector-python") except Exception as e: print(f"An error occurred: {e}")