tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

mssql named instance port number

Open adi1 opened this issue 1 year ago • 0 comments

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};"

adi1 avatar Mar 11 '24 10:03 adi1