I would like to access a SQL server from windows 10 using python and pyodbc, not with the account i currently am logged in windows but with a different windows account
runan different user cannot work because the user that have access to the DB has not access to python directory nad i can include him in the users of my PC
Is it possible?
2条答案
按热度按时间hujrc8aj1#
So, I ended up solving this not using
pyodbc
but usingpymssql
instead. I'm not sure if that help OP though. Just figured I'd share.wmvff8tz2#
Actually the way proposed by Tim Griffith on 1st April 2022 works pretty well also with pyodbc (so it's suitable as solution of the topic). You just should consider the error codes and results returned by Windows API before further processing to avoid error messages like one named in comment to Tim's answer. I've tested it on Windows 10, here is the complete code: