integrated_crm_app/test_db_conn.py
yumoqing 2b921a209d sync: local modifications to integrated_crm_app
- Updated app/integrated_crm_app.py, build.sh, conf/config.json
- Added config.ini, schema.sql, send_email.py, test_db_conn.py
- Added full wwwroot/ with bricks framework, all module frontends, login/main UI
2026-04-28 18:54:07 +08:00

45 lines
1.0 KiB
Python

#!/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}")