Accessing multiple databases #3217
-
What would be the best way to go about accessing multiple databases? Currently, I'm using the db_url in the rxconfig file for the main database and passing the whole connection string for a second database in the rx.session(). Is there a cleaner, more secure way to do it with a second db_url or something in the rxconfig file? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
There's to a really a builtin way to do this as it would be hard to map the models to the corresponding database. If you need this, the way you're doing it seems like a good option. We're open to suggestions on how we can make the API nicer for these use cases. |
Beta Was this translation helpful? Give feedback.
-
Related project: https://github.com/febus982/sqlalchemy-bind-manager |
Beta Was this translation helpful? Give feedback.
@chimeracle Currently the models aren't really tied to a database, it's the sessions themselves. Could you use your original approach with a helper function to achieve this? I think it should be pretty clean: