""" 检查数据库表结构 """ import sys import os # 添加项目根目录到 Python 路径 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from app.core.database import engine from sqlalchemy import text with engine.connect() as conn: # 显示所有表 result = conn.execute(text('SHOW TABLES')) tables = [row[0] for row in result] print("Tables in database:") for table in tables: print(f" - {table}") # 检查users表结构 if 'users' in tables: print("\nUsers table structure:") result = conn.execute(text('DESCRIBE users')) for row in result: print(f" {row[0]}: {row[1]}")