A SQLAlchemy middleware for FastAPI
pip install fastapi fastalchemy
- Super-easy configuration: simply put
models.pyfiles in your project folder with the following code.
from fastapi import FastAPI from fastalchemy import SQLAlchemyMiddleware, db from models import User app = FastAPI() app.add_middleware(SQLAlchemyMiddleware) @app.get('/users') def get_users(): return db.query(User).order_by(User.id).all()
tests/app folder if you want to know the way to create
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.