40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import os
|
|
import sys
|
|
|
|
# 添加项目根目录到Python路径
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from app import create_app, db
|
|
|
|
# 创建应用实例
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
try:
|
|
# 测试数据库连接
|
|
db.engine.connect()
|
|
print("✓ Database connection successful")
|
|
|
|
# 检查表结构
|
|
from sqlalchemy import inspect
|
|
inspector = inspect(db.engine)
|
|
tables = inspector.get_table_names()
|
|
print(f"Database tables: {tables}")
|
|
|
|
# 检查 admin 表结构
|
|
if 'admin' in tables:
|
|
columns = inspector.get_columns('admin')
|
|
print("Admin table columns:")
|
|
for col in columns:
|
|
print(f" - {col['name']}: {col['type']}")
|
|
|
|
# 检查是否有 is_deleted 字段
|
|
has_is_deleted = any(col['name'] == 'is_deleted' for col in columns)
|
|
print(f"Has is_deleted column: {has_is_deleted}")
|
|
else:
|
|
print("Admin table not found")
|
|
|
|
except Exception as e:
|
|
print(f"✗ Database connection failed: {e}")
|
|
import traceback
|
|
traceback.print_exc() |