Python: post #2263650 — TG.ME

Nandu Barui👋 Hello everyone! I hope you guys are familiar with FastAPI, SQLModel, and Pydantic. I’m trying to understand something by reading the docs about how SessionDep works in FastAPI 🙏 When i came across the examples def get_session(): with Session(engine)…
Why are you jumpimg from Flask to FastAPI - to use SQLmodel?? What the f...

Best way to split the work is one function, one job. Update the user - 1 route, add new job listing - 1 route, etc...

And dependacies should be resolved at route level as that is how FastAPI works

You dependacies are created when request comes and destroyed when response leaves. Its request-based scoping.

An no, the get_session is not running the whole time, yield returnes the result and stops execution of function

You should learn about yield and how it works to understand get_session.

This article seams resonable to learn from
https://amitamola.medium.com/understanding-yield-in-python-b11e7e23d674
August 24, 2026