Python - The SQL Server server does not exist or access to it has been denied

0

The next string connection perfectly connects to the destination server:

Import pyodbc
cnn = pyodbc.connect('DRIVER={SQL Server};SERVER=MyServer;DATABASE=MyDb;UID=xxxx;PWD=xxxx')
Print ("Conectado")

But when I try to connect to an instance of that server

Import pyodbc
cnn = pyodbc.connect('DRIVER={SQL Server};SERVER=MyServer\MyInstance;DATABASE=MyDb;UID=xxxx;PWD=xxxx')
print ("Conectado")

I get the error:

  

Error: ('08001', '[08001] [Microsoft] [ODBC SQL Server   Driver] [DBNETLIB] The SQL Server does not exist or the server has been denied   access to it. (17) (SQLDriverConnect) ')

The point is that I must access that instance of the database to work with the test tables that it has.

How can I solve this?

    
asked by Felipe Lujan 21.11.2017 в 18:20
source

1 answer

0

Finally I managed to solve: It turns out that when I enter via SSMS the name of the instance I write it in lowercase and there is no problem, but Python is susceptible to uppercase and lowercase. I just wrote the name of the instance in uppercase and problem solved

    
answered by 28.11.2017 в 23:37