8

I can not get rid of the error.

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

  1. Put

heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

  1. Create file Aptfile.
unixodbc
unixodbc-dev
python-pyodbc
libsqliteodbc
https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/msodbcsql_13.1.9.2-1_amd64.deb
  1. Create file requirements.txt
...
pyodbc
django-pyodbc-azure
  1. settings.py
DATABASES = {
    'default': {
    'ENGINE': 'sql_server.pyodbc',
    'NAME': '',
    'USER': '',
    'PASSWORD': '',
    'HOST': '',
    'PORT': '',
    'OPTIONS': {
        'driver': 'ODBC Driver 13 for SQL Server',
        'MARS_Connection': 'True',
        }
    }
}

How to fix this error I do not know

AS Mackay
  • 2,831
  • 9
  • 19
  • 25
TiRuRi
  • 81
  • 5
  • Any luck on this mate? I have asked Heroku to help, but it does not seem like they are used to having to connect to Azure SQLServer databases. – Games Brainiac Mar 05 '19 at 20:21

1 Answers1

1

I believe this can be solved with the same methodology as a similar question Python cant find ODBC Driver on Heroku after setting everything.

tldr: the solution was to precompile ODBC Driver 17 for SQL Server on an Ubuntu 18.04 environment and copy the required driver files over to Heroku via this buildpack https://github.com/matt-bertoncello/python-pyodbc-buildpack.git.

m.b
  • 311
  • 3
  • 8