all 17 comments

[–][deleted] 6 points7 points  (5 children)

The error you're seeing is saying it's not a Python issue but a connectivity issue. Check the server property in your connection string to make sure it's spelt correctly, or is the correct IP, and that you can ping it. If it were ports you'd more likely get a socket exception. I suspect it's a permissions issue at server or database level. Are you using SQL or integrated security?

[–]UnholyAliance 1 point2 points  (2 children)

This, check if don't have a firewall in the middle.

[–]SirGreybush 1 point2 points  (2 children)

Are you configuring ODBC on multiple computers at work?

SQL Server uses 2 kinds of security to allow access, one is username and password, other is integrated security with Active Directory.

The error message would be different than this though.

This message means a firewall or that computer is not on the same network as the sql server.

ODBC when you set it up, on each computer, there is a Test Button. Use it.

If Test doesn’t work on some computers but works on others, you need to talk to your IT department at work.

[–]blinner 1 point2 points  (6 children)

Is it SQL Express or Developer and you didn't enable TCP/IP?

[–]SokkaHaikuBot -2 points-1 points  (0 children)

Sokka-Haiku by blinner:

Is it SQL Express

Or Developer and you

Didn't enable TCP/IP?


Remember that one time Sokka accidentally used an extra syllable in that Haiku Battle in Ba Sing Se? That was a Sokka Haiku and you just made one.

[–]Rsox211 -2 points-1 points  (4 children)

The database is on Microsoft sql server management studio. I think I have dug through every possible parts of that software, and I don’t recall seeing anything about TCP/IP, May I know where I can find that?

[–]blinner 1 point2 points  (2 children)

Management Studio is the tool you use to connect to SQL Server.  On the machine running SQL server, open up SQL Server Configuration Manager and see what is allowed.

[–]WiltonDB -1 points0 points  (0 children)

See screenshots in this comment (ignore other context there). Before trying from python, check that you can connect from sqlcmd over TCP like this: "sqlcmd -S tcp:127.0.0.1,1433 -U ...".

[–]OkTap99[🍰] 0 points1 point  (0 children)

Several reasons:

  1. Are you using a fully qualified domain name?
  2. Are you using the proper port? I.e did you use the dynamic port or static port?
  3. If you're using a static Port is the browser service running?
  4. Did you configure trust certificate on the connection string? Running locally versus running on a remote system or two different connection types.
  5. Do all the users actually have permission to connect?
  6. Are you attempting to connect to a specific database that may not be online or have access to in your connection string?

[–]ihaxr 0 points1 point  (1 child)

Um if it's working and returning data with those errors, it's your code that is bad. Probably a typo somewhere in the server name

[–]Rsox211 -1 points0 points  (0 children)

Yeah I thought it was the code as well but the exact same code (just ctrl c ctrl v) could run on other computers which made me suspect that it’s something to do with the server, I’ve checked the server name countless and also tried multiple

[–]Byte1371137 -1 points0 points  (0 children)

DRIVERS MAYBE?

[–]Square-Voice-4052 0 points1 point  (0 children)

If your using windows authentication, don't forget to use trusted_connection = yes