tortoise / tortoise/tortoise-orm
mssql named instance port number
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
When connecting to an mssql named instance, the connection string generated in tortoise.mssql.client.MSSQLClient still includes the port number. Named instances listen on dynamic ports, so the ,{port} should be left out, otherwise it tries to connect by default to port 1433 which fails.
To Reproduce
Create an mssql connection with host containing a named instance, for example my_server\my_instance
Expected behavior
It should work
Additional context
One possible fix could be:
if "\\" in host:
# named instance, don't provide port
server = host
else:
server = f"{host},{port}"
self.dsn = f"DRIVER={driver};SERVER={server};UID={user};PWD={password};"
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 in tortoise.mssql.client.MSSQLClient and inspect how the connection string builds its SERVER value from the host and port. Reproduce the named-instance case with a host such as my_server\my_instance, then verify that named instances omit the port while ordinary hosts retain it and connections still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100