vaartun
vaartun

Reputation: 11

How do you use pyodbc in Azure Machine Learning Workbench

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 anywere else in the solution.

Upvotes: 1

Views: 1293

Answers (1)

Aksana Kuzmitskaya
Aksana Kuzmitskaya

Reputation: 31

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}'

Upvotes: 2

Related Questions