mobile database admin_teacher_applications check_applications migrate test_owner_access themes
This commit is contained in:
50
check_applications.py
Normal file
50
check_applications.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""
|
||||
检查教师申请数据的完整性
|
||||
"""
|
||||
import sqlite3
|
||||
|
||||
db_path = 'instance/database.db'
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
print("检查教师申请数据完整性...\n")
|
||||
|
||||
# 获取所有待审批的申请
|
||||
cursor.execute("""
|
||||
SELECT id, user_id, contest_id, name, email, status
|
||||
FROM teacher_application
|
||||
WHERE status = 'pending'
|
||||
""")
|
||||
apps = cursor.fetchall()
|
||||
|
||||
if not apps:
|
||||
print("没有待审批的教师申请")
|
||||
else:
|
||||
print(f"找到 {len(apps)} 个待审批的申请\n")
|
||||
|
||||
for app in apps:
|
||||
app_id, user_id, contest_id, name, email, status = app
|
||||
print(f"申请 ID: {app_id}")
|
||||
print(f" 用户ID: {user_id}, 杯赛ID: {contest_id}")
|
||||
print(f" 姓名: {name}, 邮箱: {email}")
|
||||
|
||||
# 检查用户是否存在
|
||||
cursor.execute("SELECT id, name FROM user WHERE id = ?", (user_id,))
|
||||
user = cursor.fetchone()
|
||||
if user:
|
||||
print(f" [OK] 用户存在: {user[1]}")
|
||||
else:
|
||||
print(f" [ERROR] 用户不存在!")
|
||||
|
||||
# 检查杯赛是否存在
|
||||
cursor.execute("SELECT id, name FROM contest WHERE id = ?", (contest_id,))
|
||||
contest = cursor.fetchone()
|
||||
if contest:
|
||||
print(f" [OK] 杯赛存在: {contest[1]}")
|
||||
else:
|
||||
print(f" [ERROR] 杯赛不存在!")
|
||||
|
||||
print()
|
||||
|
||||
conn.close()
|
||||
print("检查完成")
|
||||
Reference in New Issue
Block a user