tortoise / tortoise/tortoise-orm
project multiple schema
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
I want to realize that a project can be switched dynamically schema
The way I do this is by initializing the link on every request, But the link may be occupied or closed
Is there a way to solve a similar problem
def demo_conf_db_switch(db_base):
def func_work(func):
@functools.wraps(func)
async def wrapper(*args, **kwargs):
await Tortoise.init(db_base)
await Tortoise.generate_schemas()
data = await func(*args, **kwargs)
await Tortoise.close_connections()
return data
return wrapper
return func_work
This is how I implement the switch, dynamically passing the parameters needed for the database connection
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Tortoise.init, generate_schemas, and close_connections calls shown in the issue, along with how connection configuration is managed between requests. Clarify whether the goal is dynamic schema switching or switching complete database connections; the issue does not define acceptance criteria or a specific test for completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100