I wanted to remotely connect to a sql-server database on my network in python. So I the installed pyodbc following the steps given on this page . It instructs to first "Install the Microsoft ODBC Drivers for SQL-Server" by following these instructions.
Having completed these steps (and only these steps) I identified the driver path and tried running this code in python.
import pyodbc as podbc
conn = podbc.connect("Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1;"
"Server=192.XXX.XXX.XXX;"
"Database=db_name;"
"uid=xxxx;"
"pwd=xxxx;")
On execution I am getting the error:
pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (10054) (SQLDriverConnect)')
It would be helpful if you could tell me why am I getting this error and if I'm missing any steps in the installation process. Also, I am able to access the sql-server remotely through a windows machine, but whenever I'm trying to do it via an ubuntu machine I'm getting this error.
1条答案
按热度按时间s4n0splo1#
I encountered the same issue after building a docker image based on ubuntu:20.04 for AWS Sagemaker processing jobs. I resolved the error by installing a specific version of openssl, namely, 1.1.1p.
This was the command I added to my docker file:
This line should be added before the command that installs the appropriate Microsoft SQL Server ODBC drivers (which was msodbcsql17 in my case)