from contextlib import asynccontextmanager from fastapi import FastAPI from app.database import engine from app.routers import authors, books @asynccontextmanager async def lifespan(app: FastAPI): yield # tables already created by Create.sql await engine.dispose() app = FastAPI(title="Database API", lifespan=lifespan) app.include_router(authors.router) app.include_router(books.router)