简体   繁体   中英

domain name and connection string to SQL Server when using Python and pyodbc

when using Windows authentification with domain name and connection string to SQL Server (using Python34 and pyodbc), I still receive the following error:

cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SER
N04\SQLEXPRESS;DATABASE=BRKPNTD',UID='CZMKAJAN04\celocaladmin', PWD='xxxxxx')
pyodbc.Error: ('28000', "[28000] [Microsoft][SQL Server Native Client
Server]Login failed for user 'CZMKAJAN04\\celocaladmin'. (18456) (SQLDriverConnect)")

I don't know how to get rid of the double backslash, tried raw version of the string, various forms of escaping and nothing helped. Do you know how to solve it? Thanks a lot

SQL Server连接字符串的Windows身份验证需要Trusted_Connection参数,不能使用UIDPWD进行指定。

cnxn = pyodbc.connect('DRIVER={SQL Server Native Client 11.0};SERN04\SQLEXPRESS;DATABASE=BRKPNTD', Trusted_Connection='yes')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM