Share via

SQL Server connection string from Linux Phyton app

ACDBA 421 Reputation points
2021-07-31T17:55:22.67+00:00

I have an windows box with 4 standlone instance installed. All are set with a dynamic port. SQL Browser is running. A python app running from a Linux machine is not connecting to SQL unless we provide port number in connection string.

Do we need to provide port number in the connection string to connect from Linux?

Thank you.
ACDBA

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

2 answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,431 Reputation points Microsoft External Staff
    2021-08-02T03:24:21.02+00:00

    Hi @ACDBA ,

    Yes. You can also change the four standalone instances from dynamic port to fixed port number. You can change this from SSCM as below screenshot. Please restart the SQL server instance to make this change effect.

    119619-screenshot-2021-08-02-112100.jpg


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.

    Was this answer helpful?


  2. Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
    2021-07-31T19:08:04.113+00:00

    You need to provide port number or instance name. Keep in mind that you need to do one of:

    connString = "Server=SERVER\\INSTANCE;..."
    connString = r"Server=SERVER\INSTANCE;..."
    

    That is, either double the backslash, or prefix with r to make it a raw string. Else Python will intercept the backslash.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.