Open thatcher opened 8 years ago
This can be done, but I need to see how much refactoring is necessary. In the meantime, you're free to use a separate wsgi server per database and all will work as expected (though I realize that's not ideal).
Thanks Jeff. Appreciated.
Jeff, thanks a lot, really appreciate you looking at this! (A colleague of @thatcher )
The Flask-Admin instance retains some internal state when it is initiated, in some cases when running the unit tests and instantiating Flask-Admin outside of the application factory I have encountered an error claiming I have registered duplicate views. (I had a link somewhere to the Flask-Admin issue tracker that explained this but can't find it now.)
The Flask-SQLAlchemy instance use the "DATABASE_URL" value set upon the application. This is read whenever one invokes it directly SQLALchemy(app)
or initiates an instance, data=SQLAlchemy()
, later on database.init(app)
. My understanding is that flask supports multiple database connections through binds, but I have not used this personally. Perhaps setting this might allow you to map multiple databases in one instance but I think the Flask-Admin issue might still bite you.
Hi Jeff. We have many legacy databases we are trying to do some data extraction on. We initially set up our approach using a single db/wsgi.py which does something like:
in
foo/services/goop.py
andfoo/services/blah.py
we havewhere the idea is we can hit paths like:
/foo/
-> general stuff for our project/foo/goop/admin/
-> sandman2 admin for goop database/foo/blah/admin/
-> sandman2 admin for blah databaseThe problem is we see the table for both databases in both admin panels! And we get a lot of errors like:
SAWarning: This declarative base already contains a class with the same class name and module name...
The gist appears to be that there can only be one call to sandman2.get_app per wsgi as there is some class level state being set/stored and thus duplicating the information across the admin pages.
Thoughts? Is there just a better way we are missing or does it boil down to a separate wsgi per database?
Thanks! Thatcher