tortoise-orm
tortoise-orm copied to clipboard
mssql named instance port number
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};"