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
Req: concurrent use of multiple databases #1581
Comments
Hi There is example how you can use two databases Is not what you are looking for? |
Please write if I misunderstood your request |
Thanks, but the example you've given uses Can you recommend how to have one models module for a database on one server, and another models module for a database on a different server, and to access both through Tortoise ORM patterns? |
@davidmcnabnz All Explicit |
Is your feature request related to a problem? Please describe.
I need to be able to access multiple databases simultaneously, on on local machine, and 2 or more on other remote servers. But Tortoise's usage pattern suggests it's only meant for accessing one database within the one Python environment.
Describe the solution you'd like
Here's the OLD way - singleton Tortoise context:
NEW preferred way - multple distinct Tortoise contexts:
This lets me then make arbitrary access to multiple databases at once:
Describe alternatives you've considered
In production use, I am limited to using Tortoise for the local PostgreSQL database, and low-level asyncpg pooled connections to PostgreSQL databases on other servers. But I would greatly prefer to be able to wrap all databases, local and remote, within Tortoise's excellent ORM layers.
Additional context
Add any other context about the feature request here.
The text was updated successfully, but these errors were encountered: