error: client TLS version

102 views
Skip to first unread message

avigail rachman-weiner

unread,
Nov 27, 2022, 5:28:49 AM11/27/22
to pymssql
Hi,
 im trying to connect to MS SQL server using python script on linux.
my python version is 3.3.6
i already install pymssql lib

when trying to connect im getting the error: 
yymssql._mssql.MSSQLDatabaseException: (47072, b'Reason: Login failed due to client TLS version being less than minimal TLS version allowed by the server.DB-Lib error message 20018, severity 20

can i get help please how i can fix this issue

thank you 
avigail

Riaz Farooqui

unread,
Mar 5, 2023, 12:55:29 PM3/5/23
to pymssql

This error occurs when the client TLS version used by the pymssql library is lower than the minimum TLS version allowed by the SQL Server you are trying to connect to.

To resolve this error, you can try the following steps:

  1. Upgrade the pymssql library to the latest version using pip install --upgrade pymssql.

  2. Set the SSL version to be used for encryption to a higher version by specifying the ssl parameter when creating a connection to the SQL Server. For example, you can set it to ssl='TLSv1.2'.

Here's an example of how to set the ssl parameter when creating a connection to the SQL

import pymssql

# create a connection object
conn = pymssql.connect(server='your_server_name', user='your_username', password='your_password', database='your_database_name', ssl='TLSv1.2')

# execute queries using the connection

# close the connection when done
conn.close()
Reply all
Reply to author
Forward
0 new messages