Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install ODBC Driver heroku

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

like image 595
TiRuRi Avatar asked Jul 01 '18 11:07

TiRuRi


1 Answers

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.

like image 72
m.b Avatar answered Oct 16 '22 09:10

m.b