Requirements
Environment Setup
- Install dependencies
brew install unixodbc
brew install freetds
brew install openssl
brew install libiconv
TIP
如果沒有使用
poetry
的話,可以只執行下面這段指令pip install --pre --no-binary :all: pymssql --no-cache --force
- Install python with pyenv
- Change global python to previously installed one
# choice any version you prefer
PY_VERSION='3.10'
pyenv install $PY_VERSION
pyenv global $PY_VERSION
- Create virtual env with poetry
poetry env use $PY_VERSION
- Setup Compile Flags
export LDFLAGS="-L/opt/homebrew/opt/freetds/lib -L/opt/homebrew/opt/openssl@3/lib"
export CFLAGS="-I/opt/homebrew/opt/freetds/include"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
https://github.com/pymssql/pymssql/issues/727#issuecomment-1204850473
- Install
pymssql
with poetry
poetry add pymssql