I know this question has been asked many times on the web resulting in many different solutions none which have worked for me.
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.
This is the connection string that I am providing:
databaseConnection = 'DRIVER={SQL Server}; SERVER=ServerName; Database=DatbaseName; UID=UserId; PWD=password;'
This is the error I receive when trying to run the script:
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)')
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.