mfreeborn / fastapi-sqlalchemy

Adds simple SQLAlchemy support to FastAPI
MIT License
594 stars 34 forks source link

Multiple DBs #20

Open lefnire opened 3 years ago

lefnire commented 3 years ago

Is there a way to add two database connections via the middleware? Slighty edge case, but I'll dealing with a psql and a MySQL for my project

mfreeborn commented 3 years ago

I'm afraid not directly at present, but I'd be happy to go along with it if someone were willing to write up a pull request.

lefnire commented 3 years ago

Thanks for the reply. I'll try the main doc's get_db() approach first & see how it suites me, and if I end up wanting to go the fastapi-sqlalchemy path I'll submit a PR. Hopefully someone gets to it before me

Ewen-Zippedscript commented 10 months ago

Pull request #47 adds this functionality.

xhatt commented 9 months ago

Pull request #47 adds this functionality.

God, this warehouse seems to have been out of maintenance for 3 years, and it's really difficult to find middleware for FASTAPI+sqlalchemy. I found one in the past two days, but there is also a bug

Maybe you can try fork one and publish it to pypi. I guess many people will use it

The official way of using fastapi requires adding a parameter to the view, which is very inconvenient. I have to pass that parameter layer by layer before I can use database connection. Then I found this middleware. Unfortunately, it has not been maintained for a long time. If there is a useful fastapi+sqlalchemy, please remind me

This is another middleware I found.

https://github.com/h0rn3t/fastapi-async-sqlalchemy/issues/17

Ewen-Zippedscript commented 9 months ago

Hey, so I have actually packaged it and it's available using fastapi-sqlalchemy-improved on pypi.