Files
Document_Translator/init_app.py
beabigegg b11a8272c4 2ND
2025-09-02 13:11:48 +08:00

51 lines
1.3 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
初始化應用程式腳本
"""
import os
import sys
sys.path.append('.')
def init_application():
"""初始化應用程式"""
try:
print("Initializing application...")
from app import create_app
app = create_app('development')
print("App created successfully")
with app.app_context():
from app import db
print("Database tables created")
# 檢查表格是否建立
import pymysql
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("\nDocument Translator Tables:")
for table in tables:
print(f"- {table[0]}")
connection.close()
return True
except Exception as e:
print(f"Initialization failed: {e}")
return False
if __name__ == '__main__':
init_application()