Re: [flask] multi tenancy with Flask / SQL Alchemy
- Audrius Kažukauskas
- 2012-12-17 @ 14:06
On Mon, 2012-12-17 at 11:58:17 +0100, Sjoerd Huisman | Congressus wrote:
> What are the best practises to implement a multi tenancy environment in
> Flask? Flask-SQLAlchemy does not provide any service for this. We have a set
> of models where some needs to be synchronised with one (our own) database
> and other models need to be synchronised with the client database.
> Multi-bind does not work, as the client is not yet known the first time as
> the App launches.
> - One Flask App, One SqlAlchemy, One Session, Multiple Connections
> - One Flask App, One SqlAlchemy, Multiple Session, One Connection each
> - One Flask App, Multiple SqlAlchemy, One Session each, Multiple
> - Multiple Flask Allps, One SqlAlchemy each, One Session each, One
> Connection each
> - Or look into multi-threading and use one thread per tenant?
Haven't done this myself, so can only point you at this blog post,
which seems to be relevant. You may also want to check SQLAlchemy usage
recipes and mailing list archives.