0 votes
1 view
in Azure by (32.3k points)

I'm trying to use pyodbc to import a dataframe in Azure ML Workbench. This works in local runs, but not for docker. It fails when trying to establish a connection to the SQL Server, because the driver is not present.

cnxn = pyodbc.connect('DRIVER='{ODBC Driver 13 for SQL Server}';PORT=1433;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password)

Error Message:

pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)")

When searching for a solution I found that I could put these lines in the docker file

ADD odbcinst.ini /etc/odbcinst.ini

RUN apt-get update

RUN apt-get install -y tdsodbc unixodbc-dev

RUN apt install unixodbc-bin -y

RUN apt-get clean -y

However, I'm new to docker, and cannot figure out where to put these lines in the ML Workbench. It seems the docker file is generated through docker.compute and conda_dependencies.yml, but nothing similar to the lines above can be found in either of those or anywhere else in the solution.

1 Answer

0 votes
by (16.8k points)

You can build docker image with dependencies you need and specify your image name inside the docker.compute file:

baseDockerImage:<your docker image name>

I created azml_pyodbc_image, you can try to use it with:

baseDockerImage: "aksanakuzmitskaya/azml_pyodbc:firsttry"

DRIVER='{ODBC Driver 17 for SQL Server}'

Welcome to Intellipaat Community. Get your technical queries answered by top developers !