I am trying to connect to SQL Server which requires multi factor authentication. Each time when I am running script it want me to provide password. Is there any way to avoid that and provide password automatically somehow?
When I tried to use password as connection parameter it shows me this error
Password option must not be specified, if Authentication option is 'ActiveDirectoryInteractive'
Code:
con = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};"
"Server=tcp:sql-serrver.database.windows.net,1433;"
"Database=db;"
"[email protected];"
"Authentication=ActiveDirectoryInteractive")
To fix this I use ActiveDirectoryPassword authentication method instead of interactive
con = pyodbc.connect("Driver={ODBC Driver 17 for SQL Server};"
"Server=tcp:sql-serrver.database.windows.net,1433;"
"Database=db;"
"[email protected];"
"PWD=pass123;"
"Authentication=ActiveDirectoryPassword")