我正在开发一个使用Python和Flask的web应用程序。
我的应用程序使用pyobdc访问Microsoft。它在本地运行。
当我将它部署到Azure application并使用该应用程序时,当它需要访问服务器时,它会崩溃,这给了我这个错误:
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
随机细节:
我尝试使用我的Azure中的kudu终端手动安装它,使用这个ODBC驱动程序linux链接中的说明。但是当我尝试的时候,它告诉我sudo不是命令。(这是关于Azure限制或IT权限的问题吗?)
我还尝试将Server升级到ODBC驱动程序18,但没有成功。
我在一些地方读到,不支持ODBC,也不支持安装ODBC。
这是真的吗?有办法解决这个问题吗?
有没有其他方法将MS连接到部署在azure上的python烧瓶web应用程序?
我还检查了odbc.ini和odbcinst.ini文件在/etc中,发现它们是空的。
发布于 2022-10-28 19:06:36
我解决了我的问题。
我通过dockerfile为Server安装了ODBC驱动程序17。我使用了关于如何使用ODBC17Debian版本安装found 这里的说明。但是由于一些错误,它没有完全工作,所以我稍微修改了一下。
这就是我在码头上添加的内容:
#What I added to deal with the errors I was getting:
RUN apt-get update -y
RUN apt install unixodbc -y
#Installation instructions from microsoft link:
RUN su
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
#Checking the installation
RUN cat /etc/odbcinst.ini
#Create the odbc.ini file
RUN echo -e '[voip]\nDescription = whatever\nDriver = ODBC Driver 17 for SQL Server\nServer = whatever\nUser = whatever\nPassword = whatever\nPort = whatever\nDatabase = whatever' > odbc.ini
#Moving odbc.ini to the etc directory
RUN mv odbc.ini etc
#Checking contents of odbc.ini
RUN cat /etc/odbc.ini 我不得不自己编辑odbc.ini,因为它是空的。但是,在运行微软指令提供的命令之后,应该填充odbcinst.ini。
etc/odbcinst.ini应该有这样的内容:
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.1.1
UsageCount=1etc/odbc.ini应该是这样的:
[voip]
Description = whatever
Driver = ODBC Driver 17 for SQL Server
Server = whatever
User = whatever
Password = whatever
Port = whatever
Database = whatever如果您有此问题,您将不得不自己编辑odbc.ini。但我所做的是创建一个odbc.ini文件。然后把它转移到/etc中。
https://stackoverflow.com/questions/74199557
复制相似问题