From e2ccae757c3f4bc59c3c506047c78d38109e7285 Mon Sep 17 00:00:00 2001 From: Orangeeee Date: Tue, 22 Sep 2026 15:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edatabases.py=E6=8A=8A?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=BB=BA=E8=A1=A8=E5=9F=BA=E7=B1=BB=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E6=88=90=E4=B8=80=E4=B8=AA=EF=BC=8C=E6=89=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=93=BE=E6=8E=A5=E5=A4=96=E9=94=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 6 +++++- students/StudentsQuery.sql | 4 ++++ students/main.py | 8 +------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 7dda036..af45b3c 100644 --- a/main.py +++ b/main.py @@ -4,15 +4,19 @@ from scores.main import Scores_API from stu_jiuye.main import Shtudent_Jiuye from students.main import Students_API from Teachers.main import Teachers_API - +from databases import * app = FastAPI(title="学生管理系统") +Base_all.metadata.create_all(bind=engine_all) + app.include_router(Classes_API,tags=["classes"]) app.include_router(Scores_API,tags=["scores"]) app.include_router(Shtudent_Jiuye,tags=["Employments"]) app.include_router(Students_API,tags=["students"]) app.include_router(Teachers_API,tags=["teachers"]) + + def main(): print("Hello from student-manage-system!") diff --git a/students/StudentsQuery.sql b/students/StudentsQuery.sql index 16b6e74..87eb3b4 100644 --- a/students/StudentsQuery.sql +++ b/students/StudentsQuery.sql @@ -6,7 +6,11 @@ use student_manage_system; show tables; +drop database student_manage_system; + drop table students; select * from students limit 50; +desc students; + diff --git a/students/main.py b/students/main.py index 8dddae6..b6fd5f9 100644 --- a/students/main.py +++ b/students/main.py @@ -5,13 +5,7 @@ from students.model import students_model from contextlib import asynccontextmanager # 合并接口 -@asynccontextmanager -async def S_Router(Students_API: APIRouter): - Base.metadata.create_all(engine1) - yield - engine1.dispose() - -Students_API = APIRouter(lifespan=S_Router) +Students_API = APIRouter() Students_API.include_router(s_api) # 自测接口