def get_db():
db = SessionLocal()
try:
return db
finally:
db.close()
I got this code snipped to get Sessionlocal in fastapi with Sqlalchemy. Well, when I used return instead of Yield. My code still works. Then, I do not understand the reason of using Yield. Can someone help me?
