Kamixitong/check_mysql_data.py
2025-11-11 23:04:01 +08:00

31 lines
884 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
import sys
# 添加项目根目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# 在导入应用之前加载环境变量
try:
from dotenv import load_dotenv
if load_dotenv():
print("成功加载.env文件")
except ImportError:
print("python-dotenv未安装跳过.env文件加载")
from app import create_app, db
from app.models.admin import Admin
# 创建应用实例
app = create_app()
with app.app_context():
try:
# 检查管理员数据
admins = Admin.query.all()
print(f"Found {len(admins)} admin users:")
for admin in admins:
print(f" - ID: {admin.admin_id}, Username: {admin.username}, Role: {admin.role}, Status: {admin.status}")
except Exception as e:
print(f"Database query failed: {e}")
import traceback
traceback.print_exc()