3
I am trying to connect to SQL Server 2012 using Python 3.7 and Ubuntu 20.04.1 LTS as follows:
import pyodbc
server = 'tcp:192.168.0.7, 1433'
database = 'teste'
username = 'teste'
password = 'teste'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
While trying the connection I get the following error message:
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password) pyodbc.Operationalerror: ('08001', '[08001] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:Unsupported Protocol] (-1) (Sqldriverconnect)')
I read a topic in git about and even got to test a downgrade in openssl but still could not make it work.
I have 2 versions of SQL I just noticed that: In version 11.0.2100.60 and I have the error I described at the beginning. In version 11.0.6020.0, I noticed now that I get a different error:
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+' ;PWD=' + password+';Encrypt' + Encrypt) pyodbc.Operationalerror: ('08001', '[08001] [unixODBC][Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10054) (Sqldriverconnect)')
To install ODBC on Ubuntu 20.04, did you follow the steps of "Install Microsoft ODBC Driver for SQL Server (Linux)"? -> https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sqlallproducts-allversions
– José Diz
Also check that SQL Server 2012 instance has installed support for TLS 1.2. " TLS 1.2 support for Microsoft SQL Server" -> https://support.microsoft.com/en-us/help/3135244/kb3135244-tls-1-2-support-for-microsoft-sql-server
– José Diz
To install the ODBC Driver for SQL Server (Linux) was exactly this step by step that I followed, I will check the second link.
– wilian
@Josédiz, from what I understand on the microsoft site my version of SQL does not support the correct connection? I added 2 instances I have in different versions, in the newer version I noticed that the error is different.
– wilian
Are you sure the variable
server
is correct? It shouldn’t just beserver = '192.168.0.7'
?– Paulo Marques
@Paulomarques Yes, link I consulted at doc
– wilian
@Wilian, based on documentation
# server = 'myserver,port' # to specify an alternate port
has no space after the comma. It doesn’t hurt to try...– Paulo Marques
@Paulomarques test, same error, tried like this: server = 'myserver,port', server = 'tcp:myserver,port' server = 'tcp:myserver' in new sql version always the error ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10054) (Sqldriverconnect)')
– wilian
@Wilian, based on the first message, the error is SSL, no problem with the connection, but with the negotiation... See this post
– Paulo Marques
from what I read in git, what happens is that there is an attempt being made to connect with tsl 1.2 and the version of the updated sql server only allows 1.0, it would be interesting to update the bd or downgrade the driver
– Lucas Miranda
@Willian The images you added in the description do not refer to the version of SQL Server but to the components of Management Studio.
– José Diz