Django mssql-django is error in MacOS but it is working on Windows
I have already installed pip install mssql-django on MacOS. It was working fine for a while after that stop executing the program ( python3 manage.py runserver) and display message error below:
django.db.utils.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
DB setting:
'default':{
'ENGINE': 'mssql',
'NAME': 'dbname',
'HOST': 'x.x.x.x',
'PORT': '1433',
'USER': 'sa',
'PASSWORD': 'xxxx',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
}
It is working fine on Windows but not working on MacOS why?
I have already installed pip install mssql-django on MacOS.
This is not the issue. mssql-django
needs a system library. What the package does is generating queries for the MS SQL server dialect. But the connection and management of an MSSQL server is not defined by the project, for that it uses the ODBC driver.
You can install the ODBC driver through brew
by following the instructions on the Microsoft learn website [msdn-doc]:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update HOMEBREW_ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
I would however advise to use instructions by the link [msdn-doc] since the ones in this answer might eventually get outdated.