title: "Login timeout expired" error when accessing MS SQL db via sqlalchemy and pyodbc
body: <p>So I have some trouble getting sqlalchemy and pyodbc working with a remote MS SQL Server. Local sqlcmd worked properly but not when I try to read the db via python code. Any help would be appreciated. </p>
  
  <p>Environment:</p>
  
  <ul>
  <li>Centos 7</li>
  <li>SQLCmd version: Version 17.1.0000.1 Linux</li>
  <li>MS SQL Server 6.01.7601.17514</li>
  <li>Python 2.7</li>
  </ul>
  
  <p>The following sqlcmd worked properly</p>
  
  <pre><code>sqlcmd -S {Host},{Port} -U {USER} -P {PWD} -Q "use {Database};"
  </code></pre>
  
  <p>Attempts to work with sqlalchemy or pyodbc directly didn't work. Error:</p>
  
  <p>pyodbc.OperationalError: ('HYT00', u'[HYT00] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')</p>
  
  <p>Code:
  Attempt with pyodbc</p>
  
  <pre><code>conn = pyodbc.connect(
      r'DRIVER={ODBC Driver 17 for SQL Server};'
      r'SERVER=HOST,PORT;'
      r'DATABASE=DATABASE;'
      r'UID=UID;'
      r'PWD=PWD'
      )
  </code></pre>
  
  <p>Attempt with sqlalchemy:</p>
  
  <pre><code>create_engine('mssql+pyodbc://{user}:{password}@{host}:{port}/{database}?driver={driver}'.format(
          user=user,
          password=password,
          host=host,
          database=database,
          port=port,
          driver="ODBC+Driver+17+for+SQL+Server"
      )).connect()
  </code></pre>
  
  <p>I can reproduce the error with sqlcmd if I remove the port from the command, so maybe the conn_string I am passing to pyodbc is not in the correct format?</p>