I'm having one python script which connects to the MS SQL server from windows via pyodbc. When trying with windows authentication, it is getting connected to the database, but when trying with SQL server authentication (with username and password), it is showing below error.
"('28000', "[28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'xxxx'. (18456) (SQLDriverConnect); [28000] [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'xxxx'. (18456)")".
But I'm able to connect to the SQL server using that username and password (SQL server credentials). I've enabled DB read, write permission for that user in user mapping tab, and SQL server authentication is also in an enabled state. This becomes a bottleneck. Solutions are welcome. Thanks in advance!!!.
Today I learned that in python Upper case and lower case matters the most. My previous connection string is,
conn=pyodbc.connect(r'DRIVER=SQL Server;SERVER=10.60.144.13;UID=BOT_Autoheal;PWD=bot_Aut0h3a1;DATABASE=OO_GlobalAutoHealing;TRUSTED_CONNECTION=NO';)
But actual connection string worked for me is,
conn=pyodbc.connect(r'DRIVER=SQL Server;SERVER=10.60.144.13;UID=BOT_Autoheal;PWD=bot_Aut0h3a1;DATABASE=OO_GlobalAutoHealing;Trusted_Connection=no')
So, always use Trusted_Connection=no as it is, don't try to change it to Upper case.