Ubuntu 22.04.1 LTS
pyodbc 4.0.35
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Followed steps on Install the Microsoft ODBC driver for SQL Server (Linux)
Installation successful. When I run this snippet
def select_driver():
"""Find least version of: ODBC Driver for SQL Server."""
drv = sorted([drv for drv in pyodbc.drivers() if "ODBC Driver " in drv and " for SQL Server" in drv])
if len(drv) == 0:
raise Exception("No 'ODBC Driver XX for SQL Server' found.")
return drv[-1]
print(select_driver())
Output is : ODBC Driver 18 for SQL Server
My connection string .
cnxn_str = ("Driver={SQL Server Native Client 18.0};"
"Server=xx;"
"Database=xx;"
"UID=xx;"
"PWD=xx")
myCon = pyodbc.connect(cnxn_str)
Edit: With new connection "Driver={ODBC Driver 18 for SQL Server};"
[Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)')
EDIT: root@vps:~# openssl version -a
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022) built on: Thu Oct 27 17:06:56 2022 UTC platform: debian-amd64 options: bn(64,64) compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -Wa,--noexecstack -g -O2 -ffile-prefix-map=/build/openssl-WsPfAX/openssl-3.0.2=. -flto=auto -ffat-lto-object s -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-sec urity -DOPENSSL_TLS_SECURITY_LEVEL=2 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PI C -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 OPENSSLDIR: "/usr/lib/ssl" ENGINESDIR: "/usr/lib/x86_64-linux-gnu/engines-3" MODULESDIR: "/usr/lib/x86_64-linux-gnu/ossl-modules" Seeding source: os-specific CPUINFO: OPENSSL_ia32cap=0xffbaa2234f8bffff:0x400000283
Encrypt=no
to your connection string. – Fischer[Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)')
I didn't mentioned that I'm trying to connect to Microsoft SQL Server 2014˙˙ – Mauceripymssql._pymssql.OperationalError: (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (x1434)\n')
– Mauceriopenssl version -a
on your Ubuntu 22.04 machine. If the output includes-DOPENSSL_TLS_SECURITY_LEVEL=2
then it means that the library has not been built with TLS 1.0 or TLS 1.1 support, so no amount of tweaking the openssl.cnf file will allow you to connect to older servers without TLS 1.2 support. That fact that you're on SQL Server 2014 and still having this problem suggests that the server owner is bad at installing service packs and updates - it really should have TLS 1.2 support. – Gilmagilman-DOPENSSL_TLS_SECURITY_LEVEL=2
– MauceriThe version of SQL Server instance NAME does not match the version expected by the SQL Server update. The installed SQL Server product version is 12.0.2000.8, and the expected SQL Server version is 12.3.6024.0.
– Mauceri