tortoise / tortoise/tortoise-orm
exception `You are running with multiple databases` with no connections
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the bug
I am using the initializer function for my tests but when I try to get_connection, de default one, it actually throws me an error because Tortoise._connections is empty. That is because that function actually empties the dictionary. The thing is that get_connection use that as the source of connections but in reality is current_transaction_map dict.
tortoise.exceptions.ParamsError: You are running with multiple databases, so you should specify connection_name: []
To Reproduce
Steps to reproduce the behavior, preferaby a small code snippet.
- call
initializerfunc - call
get_connection()
Expected behavior
To actually get the connection.
Additional context
This error actually popped me when trying to use in_transaction or atomic functions.
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
Trace the initializer and get_connection entry points, then compare how Tortoise._connections and current_transaction_map are populated and read. Reproduce the empty-connection case after initializer; done means get_connection() returns the default connection and in_transaction or atomic no longer raises the multiple-databases error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100