How do you use pyodbc in Azure Machine Learning Workbench

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:09:18

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/48885715/how-do-you-use-pyodbc-in-azure-machine-learning-workbench

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!