title: How to connect to a SQL server linked server in Python
body: <p>Normally, when trying to connect to a SQL sever DB in Python, I use the <code>pyodbc</code> package like this:</p>
  
  <pre><code>import pyodbc
  conn = pyodbc.connect("Driver={SQL Server};"
                        "Server=&lt;server-ip&gt;;"
                        "Database=&lt;DB-name&gt;;"
                        "UID=&lt;user-name&gt;;"
                        "PWD=&lt;password&gt;;"
                        "Trusted_Connection=yes;"
                        )
  </code></pre>
  
  <p>However, I don't know how to connect to a <strong>linked server</strong> in Python. If my linked server is called <code>linked-server</code> and has a DB called <code>linked-DB</code> for example; I have tried the same connection string as above, and changing the database name like this: <code>"Database=&lt;linked-server&gt;.&lt;linked-DB&gt;;"</code>, since that's how I query the linked server DB in SSMS. But this doesn't work in Python.</p>
  
  <p>Thank you very much for your help.</p>