This commit is contained in:
beabigegg
2025-09-02 13:11:48 +08:00
parent a60d965317
commit b11a8272c4
76 changed files with 15321 additions and 200 deletions

51
test_db.py Normal file
View File

@@ -0,0 +1,51 @@
#!/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()