Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple databases binding #294

Open
1 task done
ZeeD opened this issue Oct 12, 2023 · 0 comments
Open
1 task done

Add support for multiple databases binding #294

ZeeD opened this issue Oct 12, 2023 · 0 comments

Comments

@ZeeD
Copy link

ZeeD commented Oct 12, 2023

Things to check first

  • I have searched the existing issues and didn't find my feature already requested there

Feature description

SQLAlchemy let you work with multiple databases.
In this case, apart from settings the connections with SQLALCHEMY_BINDS it's necessary to associate each Model/Table with the usage of the class attribute __bind_key__ / the parameter bind_key, as described in the documentation.

It would be nice if this information could be handled by a new option - in addition to the ones described in the readme to automatically set this value.

Use case

In my experience, the need of "reverse engineering" the data model from the db is when you want to import a "third-part" db.
In my current case, the "main" db is handled "normally" (I have a flask-based webapp, where I've defined the model, and used flask-sqlalchemy to generate the schema of the db), but I need to access this external db to fetch some additional data.
In this case - as is a "staging area" db, the schema is "out of my control". I can at most use sqlacodegen to infer the Tables in my project.
But - as things are - this also mean that the connection to this db is in addition to the "default one" I already use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant