Skip to content

fastapi-repl

Django's shell_plus, for FastAPI and every other ASGI framework.

fastapi-repl opens an interactive Python shell with your project already loaded: every model, your database engine and a ready-to-use session, the helpers you always import, and anything else you ask for. Top-level await works in every supported shell, on a single event loop that owns your async connection pool.

$ fastapi-repl
In [1]: await session.scalar(select(func.count(User.id)))
Out[1]: 1284

Why

FastAPI deliberately has no management commands, so there is no manage.py shell. Most teams end up with a scripts/shell.py that imports a few things and calls asyncio.run() on every query. It breaks with async drivers, forgets new models and is copied from project to project. fastapi-repl is that script, done properly.

Highlights

Where next

Note

fastapi-repl is an independent project and is not affiliated with FastAPI.