Remote connection to MS SQL - Error using pyodbc vs success using SQL Server Management Studio
<p>I have a MS SQL database in the same network but in other computer.
Using the SQL Server Management Studio (SSMS) Express, I can find the database and connect without problems.</p>

<p>But when I use pyodbc to connect to the same server using:</p>

<pre><code>import pyodbc

server = r"xxxER\xxxSQLSERV"
db = "xxxDB"
user = "xxx"
password = "xxxx"
conn = pyodbc.connect('DRIVER={SQL Server};SERVER='+server + ';DATABASE=' + db +';UID=' + user + ';PWD=' + password)
</code></pre>

<p>I get following error:</p>

<pre><code>pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC SQL Server Driver]Login timeout expired (0) (SQLDriverConnect)')
</code></pre>

<p>OBS: I guess that the server string should be right, since if I change it I get always the following error:</p>

<pre><code>pyodbc.Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)')
</code></pre>

<p>Here the image showing success while using SQL Server Studio Express to connect remotely.</p>

<p><a href="https://i.stack.imgur.com/BLFIV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BLFIV.png" alt="enter image description here"></a></p>