Stack Overflow Asked by Christopher Ell on January 18, 2021
I am using Python 3.7 and for a few years I have had a Python script that connected to an SQL server with the below code:
con_string = 'DRIVER={SQL Server};SERVER='+ server +';DATABASE=' + database
cnxn = pyodbc.connect(con_string)
cursor = cnxn.cursor()
Recently when running the script I get the below error:
OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen (SECCreateCredentials()). (1)')
I am not quite sure how to interpret this and have tried looking for solutions but had trouble understanding much of it?
Thanks
Update 18 August 2020
With Gords help I have updated my drivers and built a new connection string based on the answer below:
Pyodbc error Data source name not found and no default driver specified paradox
con_string = 'DRIVER={ODBC Driver 17 for SQL Server};TrustServerCertificate=No;Network=DBMSSOCN;DATABASE='+database+';WSID=L13-CHRISTOPHER;APP={Microsoft® Windows® Operating System};Trusted_Connection=Yes;SERVER='+server+';'
But I am still getting the error
OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen (SECCreateCredentials()). (1)')
Thanks
Method-1:- Check this out:
con_string = pyodbc.connect(driver='{SQL Server}', host=server, database=db1, trusted_connection=tcon)
cursor = cnxn.cursor()
If Method-1 doesn't work for you then maybe your SQL Server drivers require TLS 1.0 which would be disabled on your computer. Changing to the newest version of SNAC will fix the problem for you
con_string = pyodbc.connect(driver='{SQL Server Native Client 11.0}', host=server, database=db1, trusted_connection=tcon)
Answered by Ansh on January 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP