You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
716 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
数据库初始化脚本
"""
from backend.database import init_db, engine
from backend.models import Base
def main():
"""初始化数据库"""
print("正在初始化数据库...")
try:
# 创建所有表
Base.metadata.create_all(bind=engine)
print("数据库初始化成功!")
print("表已创建students, rollcall_records, score_records")
except Exception as e:
print(f"数据库初始化失败: {e}")
print("\n请检查:")
print("1. MySQL数据库是否已安装并运行")
print("2. backend/config.py 中的数据库配置是否正确")
print("3. 数据库是否已创建")
if __name__ == "__main__":
main()