新增databases.py把所有建表基类统一成一个,才可以链接外键。
This commit is contained in:
@@ -4,15 +4,19 @@ from scores.main import Scores_API
|
|||||||
from stu_jiuye.main import Shtudent_Jiuye
|
from stu_jiuye.main import Shtudent_Jiuye
|
||||||
from students.main import Students_API
|
from students.main import Students_API
|
||||||
from Teachers.main import Teachers_API
|
from Teachers.main import Teachers_API
|
||||||
|
from databases import *
|
||||||
app = FastAPI(title="学生管理系统")
|
app = FastAPI(title="学生管理系统")
|
||||||
|
|
||||||
|
Base_all.metadata.create_all(bind=engine_all)
|
||||||
|
|
||||||
app.include_router(Classes_API,tags=["classes"])
|
app.include_router(Classes_API,tags=["classes"])
|
||||||
app.include_router(Scores_API,tags=["scores"])
|
app.include_router(Scores_API,tags=["scores"])
|
||||||
app.include_router(Shtudent_Jiuye,tags=["Employments"])
|
app.include_router(Shtudent_Jiuye,tags=["Employments"])
|
||||||
app.include_router(Students_API,tags=["students"])
|
app.include_router(Students_API,tags=["students"])
|
||||||
app.include_router(Teachers_API,tags=["teachers"])
|
app.include_router(Teachers_API,tags=["teachers"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Hello from student-manage-system!")
|
print("Hello from student-manage-system!")
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ use student_manage_system;
|
|||||||
|
|
||||||
show tables;
|
show tables;
|
||||||
|
|
||||||
|
drop database student_manage_system;
|
||||||
|
|
||||||
drop table students;
|
drop table students;
|
||||||
|
|
||||||
select * from students limit 50;
|
select * from students limit 50;
|
||||||
|
|
||||||
|
desc students;
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -5,13 +5,7 @@ from students.model import students_model
|
|||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
|
|
||||||
# 合并接口
|
# 合并接口
|
||||||
@asynccontextmanager
|
Students_API = APIRouter()
|
||||||
async def S_Router(Students_API: APIRouter):
|
|
||||||
Base.metadata.create_all(engine1)
|
|
||||||
yield
|
|
||||||
engine1.dispose()
|
|
||||||
|
|
||||||
Students_API = APIRouter(lifespan=S_Router)
|
|
||||||
Students_API.include_router(s_api)
|
Students_API.include_router(s_api)
|
||||||
|
|
||||||
# 自测接口
|
# 自测接口
|
||||||
|
|||||||
Reference in New Issue
Block a user