mirror of
https://github.com/jeffknupp/sandman2.git
synced 2026-04-25 00:25:49 +03:00
[GH-ISSUE #86] Auto-discovery on multiple DBs #54
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
pull-request
question
refactoring
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sandman2-jeffknupp#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ibstelix on GitHub (Mar 4, 2019).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/86
Hello dear @all
I spent the whole day try to hack sandman2 to make it support multiple DBs via SQLALCHEMY_BINDS :)
I failed, any guidance to which path i should follow ?
I want provide SQLALCHEMY_BINDS intead (or in addition) of database_uri and autogenerate all the resources of the tables in SQLALCHEMY_BINDS DBs.... Lazyman here :(
@jeffknupp commented on GitHub (Mar 8, 2019):
This is technically possible but would require a decent amount of development work. I'll need to do a bit more research into what would be required.
@ibstelix commented on GitHub (Mar 9, 2019):
Thank you that will make it even greater 👍
@Carelvd commented on GitHub (Nov 5, 2019):
@ibstelix I presently have a similar need, my fork, and associated PR, refactor Sandman 2 into a structure that might be easier to hack upon.
The
SQLAclhemyinvocation under thedatabase.pyfile needs to be converted into a factory method of sorts, or it must be included within theapplicationfactory underapp.pyas I understand it. TheAdmininstantiation, underadministration.py, works similarly as I understand it.The trick, however, involves providing an instance of
SQLAclhemyduring the creation ofAutomapModelsuch that users may subclass the latter to override the models/tables of interest to them. Since SQLAlchemy seems to bind the two together it becomes a bit dicy and one essentially has to make the two instances globally available. This is fine for a single DB and associated instances ofSQLAclhemyandAutomapModeland is presently done in Sandman 2. In my refactoring I think I've gotten the structure correct to allow for multiple databases by creating a model first before creating the declarative base; which is then used to create the deferred base/AutomapModel.It now becomes possible for users to subclass Model and then for use to invoke the latter methods within the app factory, once per database. I am still setting up to try this however.
@Pmoshbr commented on GitHub (Dec 3, 2021):
Any news ?? How to allow multiples databases at a single instance of sandman2 ??