#!/usr/bin/env python3
"""Test database connection with various methods"""
import pymysql

# Test different connection methods
tests = [
    {
        'name': 'hermes via TCP',
        'params': {
            'host': '127.0.0.1',
            'port': 3306,
            'user': 'hermes',
            'password': 'hermes123',
        }
    },
    {
        'name': 'hermes via socket',
        'params': {
            'unix_socket': '/run/mysqld/mysqld.sock',
            'user': 'hermes',
            'password': 'hermes123',
        }
    },
    {
        'name': 'hermesai via TCP',
        'params': {
            'host': '127.0.0.1',
            'port': 3306,
            'user': 'hermesai',
            'password': 'hermesai',
        }
    },
]

for test in tests:
    try:
        conn = pymysql.connect(**test['params'])
        print(f"[OK] {test['name']}")
        cur = conn.cursor()
        cur.execute('SELECT 1')
        print(f"  Result: {cur.fetchone()}")
        conn.close()
    except Exception as e:
        print(f"[FAIL] {test['name']}: {e}")
