tortoise / tortoise/tortoise-orm

database connection not established after calling Tortoise.init

Open
#1,445 1 comment 0 reactions 0 assignees View on GitHub

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 configure the orm with Tortoise.init. I can specify any connection data (host, port, user, password) there and no exception will be thrown

To Reproduce

host = "wrong_host"
port = 1234
user = "wrong_user"
password = "wrong_password"
sslmode = "require"

con_str = f"postgres://" \
          f"{user}:{password}" \
          f"@{host}:{port}" \
          f"/{db_name}" \
          f"?ssl={sslmode}"

await Tortoise.init(
    db_url=con_str,
    modules={"models": model_paths}
)

Expected behavior
I'm expecting some kind of exception to be thrown. So that I can understand that I entered the wrong data for the connection. Now I have to do some database queries to understand that I did something wrong. Can I somehow force a connection to the database without making additional queries?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Tortoise.init and reproduce the issue with the invalid PostgreSQL connection string shown in the report. Trace when connection errors are surfaced, then add a regression test demonstrating that invalid connection data raises during initialization rather than only on a later query.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.