We are deploying an app via a docker image into openshift. The app is using below. We’ve tried different ways to fixing the issue, with different drivers/versions of python, editing *.ini files inside the docker container, but without any success.
A simple connection test inside the docker generate the same error, as when we start the app inside openshift, see below. Any suggestions???
cnxn = pyodbc.connect(‘DRIVER={ODBC Driver 17 for SQL Server};SERVER=’+server+‘;DATABASE=’+database+‘;UID=’+username+‘;PWD=’+ password)
Traceback (most recent call last):
File “”, line 1, in
pyodbc.Error: (‘IM004’, “[IM004] [unixODBC][Driver Manager]Driver’s SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect)”)
app component
FROM python:3.7
MS SQL server, version 13.0.5026.0.
Django==2.1
django-mssql-backend==2.8.0
django-pyodbc-azure
- settings.py -
DATABASES = {
‘dev’: {
‘ENGINE’: ‘sql_server.pyodbc’,
‘NAME’: ‘dbName’,
‘HOST’: ‘dbHost’,
‘USER’: ‘dbUser’,
‘PASSWORD’: ‘dbPass’,
‘OPTIONS’: {
‘driver’: ‘ODBC Driver 17 for SQL Server’,
}
}
- Docker -
-
OS
I have no name!@*************:/usr/src/app$ lsb_release -sirc
Debian
10
buster -
relevant script inside docker
populate “ocbcinst.ini”
#RUN echo “[FreeTDS]\n
#Description = FreeTDS unixODBC Driver\n
#Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\n
#Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so” >> /etc/odbcinst.ini
RUN echo “[ODBC Driver 17 for SQL Server]\n
Description=Microsoft ODBC Driver 17 for SQL Server\n
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.5.so.2.1\n
UsageCount=1\n
Trace=Yes” >> /etc/odbcinst.ini
RUN echo “[MSSQLServer]\n
Driver = ODBC Driver 17 for SQL Server\n
hostname = dbHost\n
Database = dbName” >> /etc/odbc.ini