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.
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¶
- ORM agnostic. Built-in adapters for SQLAlchemy (sync and async), SQLModel and Tortoise ORM, plus a small plugin API for anything else.
- Top-level
awaitin IPython, ptpython, ptipython and plain Python, all on one shared event loop. - Auto-imports: models, ORM helpers, your own imports and objects, with collision handling and aliases.
- Runs your app's lifespan on request, so startup code is live in the shell.
- Everything shell_plus does:
--print-sql,-c, stdin, scripts, Jupyter,dont_load, pre/post imports and more. See Migrating from Django. - Great ergonomics:
initwrites your config,configshows where each value came from,doctorfinds problems,importslists every name.
Where next¶
- Getting started: install, configure and run your first query.
- Configuration: every setting, with env vars and flags.
- CLI reference: every command and option.
- Recipes: common setups and tricks.
Note
fastapi-repl is an independent project and is not affiliated with FastAPI.