#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 測試資料庫連線腳本 """ import pymysql def test_database_connection(): """測試資料庫連線""" try: connection = pymysql.connect( host='mysql.theaken.com', port=33306, user='A060', password='WLeSCi0yhtc7', database='db_A060', charset='utf8mb4' ) cursor = connection.cursor() # 檢查資料表 cursor.execute('SHOW TABLES LIKE "dt_%"') tables = cursor.fetchall() print('Document Translator Tables:') if tables: for table in tables: print(f'- {table[0]}') else: print('- No dt_ tables found') # 檢查資料庫基本資訊 cursor.execute('SELECT VERSION()') version = cursor.fetchone() print(f'\nMySQL Version: {version[0]}') cursor.execute('SELECT DATABASE()') database = cursor.fetchone() print(f'Current Database: {database[0]}') connection.close() print('\n✅ Database connection successful!') return True except Exception as e: print(f'❌ Database connection failed: {e}') return False if __name__ == '__main__': test_database_connection()