1
votes

I'm trying to connect to a SQL Server using pyodbc 4.0.30 with Python 3.7. Everything was going great the past couple of days until today when I get this error:

OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error (18) (SQLDriverConnect); [08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECCreateCredentials()). (1)')`

My connection:

conn = pyodbc.connect('driver={SQL Server};server=redacted;database=uipcc_awdb;uid=redacted;pwd=redacted;trusted_connection=no;')

Please note I can connect normally to the database via SQL Server Management Studio, and no changes were made on my machine, the SQL Server, or the network.

I need to emphasize, I have tried to following which were mentioned in similar questions (but none worked):

  • adding sslverify=0 in the connection parameters
  • adding encrypt=0 in the connection parameters
  • Changing the OBDC drivers from my machine, didn't work and ruined the connection from SQL Server Management Studio
1
Does it work if you use Driver={ODBC Driver 17 for SQL Server}; in your connection string? Ref: Step 3: Proof of concept connecting to SQL using pyodbcAlwaysLearning
>>>trusted_connection=no<<< get rid of this. you pass userid and password, this parameter should not be passed at allsepupic
From stackoverflow.com/a/65924760/1467396 -> "Try changing the driver parameter from "SQL Server" to "SQL Server Native Client 11.0". This led to a successful connection for me." (and it worked for me, too)David

1 Answers

0
votes

This is most likely a TLS version issue. TLS 1.0/ TLS 1.1 has probably been disabled on the SQL Server.

There is currently an open issue on the pyodbc github tracker

And see this other question: Pyodbc giving exception with older version of sql driver but failing with latest version