fastapi-mvc icon indicating copy to clipboard operation
fastapi-mvc copied to clipboard

[Databases support] Implement Session class responsible for managing SQLAlchemy session

Open rszamszur opened this issue 1 year ago • 0 comments

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.

Feature Request

This class will be responsible for managing SQLAlchemy engine connection and session.

To figure out/clarify:

  • What SQLAlchemy engine and session/sessionmaker parameters should be configurable for the user via pydantic BaseSettings configuration class.
  • How long keep an open session? Perpetual per worker? Or per request with a context manager?
  • Only implement async session or sync as well?
  • How to pass session to FastAPI controllers? Via FastAPI Depends()? Or just do plain import and access class variable for sessionmaker object instance?
  • How to handle different database engine hacks (for instance sqlite needs connect_args={"check_same_thread": False}). Might be useful: https://github.com/pallets-eco/flask-sqlalchemy/blob/e5bf821072de0d55ff92891432004322864a7265/src/flask_sqlalchemy/init.py#L888
  • ?

rszamszur avatar Jun 21 '22 21:06 rszamszur