How to connect MSSQL to Jupyter notebook on MAC OS

Though, it seems impossible to connect MSSQL to Jupyter Notebook because you can not install MSSQL directly on your MAC OS. This tutorial will help in connecting MSSQL to Jupyter Notebook on MAC OS.

brew install msodbcsql17 mssql-tools

This will install openssl@3, microsoft/mssql-release/msodbcsql17, microsoft/mssql-release/mssql-tools

Then, you go ahead and install the package

python3 -m pip install pyodbc
pip install --upgrade pip

brew install unixodbc
brew install freetds

odbcinst -j

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql mssql-tools

odbcinst -j

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini