I am attempting to run a Python script that queries from multiple databases in SQL Server Management Studio via pyodbc. However, when I run the script I get the following error
pyodbc.InterfaceError: ('28000', "[28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'DOMAIN\\myusername'. (18456) (SQLDriverConnect); [28000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'DOMAIN\\myusername'. (18456)")
However, when I try and query the same Databases via SSMS, I can do so without an issue, so I'm frankly quite confused as to what's going on. Here's the relevant function from the Python script.
def get_999_connection(database: str):
# global dbconn_999
global dbenv
server = f'{dbenv}_999.sql.domain.org\{dbenv}_999'
print('[get_999_connection]')
# if dbconn_999 is None:
print('[get_999_connection] getting new connection')
dbconn_999_ind = pyodbc.connect(driver='{SQL Server Native Client 11.0}', server=server, database=database, trusted_connection='yes')
return dbconn_999_ind
Of course more than happy to provide any additional context or code snippets as required. Thanks so much!