mfreeborn / fastapi-sqlalchemy

Adds simple SQLAlchemy support to FastAPI
MIT License
613 stars 37 forks source link

Update to allow custom engine parameter #2

Closed guiscaranse closed 4 years ago

guiscaranse commented 4 years ago

This will allow users to pass a custom engine when in need to patch or customize the original engine class.

mfreeborn commented 4 years ago

Thanks for the pull request. What would be the use case for allowing people to pass their own custom engine instead of supplying a set of arguments as a dict with engine_args, which is already possible?

guiscaranse commented 4 years ago

Some event listeners require an engine object, you can't do that if you use this middleware because engine object get's stored inside of the middleware class. Example: https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing

EDIT: Just to be clear, this PR has more to do with being able to access the engine object instead of customizing it

mfreeborn commented 4 years ago

Sounds good to me, merged it in.