title: pyodbc connection string sql server authentication
body: <p>I know this question has been asked many times on the web resulting in many different solutions none which have worked for me. </p>
  
  <p>For my scenario I'm attempting to do a simple connection to a MS Sql database connecting just with Service account username and password using windows authentication isn't an option for my task. </p>
  
  <p>This is the connection string that I am providing: </p>
  
  <pre><code>databaseConnection = 'DRIVER={SQL Server}; SERVER=ServerName; Database=DatbaseName; UID=UserId; PWD=password;'
  </code></pre>
  
  <p>This is the error I receive when trying to run the script:</p>
  
  <pre><code>    dbConnection = pyodbc.connect(DATABASE.databaseConnection)
  pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL Server Driver]
  [SQL Server]Cannot open database "XXXX" requested by the login. The login failed.
  (4060) (SQLDriverConnect); [42000] [Microsoft][ODBC SQL Server Driver]
  [SQL Server]Cannot open database "XXXX" requested by the login. The login failed. (4060)')
  </code></pre>
  
  <p>Is there anything incorrect about this connection string? I have double checked the username and password by copy and pasting it into SQL Server Management Studio and logging into the database from there and it is successful. </p>