Skip to content

Instantly share code, notes, and snippets.

@LeeiFrankJaw
Last active May 10, 2018 15:30
Show Gist options
  • Save LeeiFrankJaw/cffc536e0a39c06fce224a87acabab0d to your computer and use it in GitHub Desktop.
Save LeeiFrankJaw/cffc536e0a39c06fce224a87acabab0d to your computer and use it in GitHub Desktop.
Install pyodbc over msodbcsql on the old Ubuntu 14.04 LTS
#!/usr/bin/env bash
# The library pyodbc requires unixodbc headers to compile, but the
# version of the unixodbc-dev provided by trusty mismatches that of
# unixodbc from the repository provided by Microsoft, so here I
# manually install the unixODBC with all things needed.
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz
tar xvf unixODBC-2.3.1.tar.gz
cd unixODBC-2.3.1/
./configure --disable-gui \
--disable-drivers \
--enable-iconv \
--with-iconv-char-enc=UTF8 \
--with-iconv-ucode-enc=UTF16LE
make
sudo make install
sudo ldconfig
# Note that the unixODBC manually installed above will shadow the
# unixodbc that will be installed as a dependency of msodbcsql17
# below, since the `/usr/local/' family of paths precede the `/usr/'
# family of paths.
sudo cat > /etc/apt/sources.list.d/mssql-release.list <<EOF
deb [arch=amd64] https://packages.microsoft.com/ubuntu/14.04/prod trusty main
EOF
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
sudo apt update
sudo apt install msodbcsql17
pip install pyodbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment