Skip to main content

(Solved) Pyodbc install fails

Comments

1 comment

  • George Birnbaum

    After debugging and testing with the PSH support team, I was able to get a passing build

    @matthias-van-woensel suggested utilizing brew for managing the dependencies, and following was my build set for this to work.


    Edit:
    After this post, I found a new flaw in my approach. I planned to use the Microsoft ODBC driver that is available via Debian package. This brought up the new concern of not being able to use Debian package managers in the PSH environment. I also had some troubles shipping the driver right in my repo, but the details below will mention how to debug the driver issues.
    https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#microsoft-odbc-driver-17-for-sql-server

    I was not previous aware of FreeTDS. FreeTDS is an open source ODBC Sql Server driver.
    http://www.freetds.org/

    Fortunately, like the unixODBC driver manage, this driver is available through homebrew. Below is my final build hook step to install all dependancies to connect to a Sql Server instance from a PSH python container.

    Below is the .odbc.ini file I used to tell register my FreeTDS driver with unixODBC that pyodbc will register. Location of this file can suit your preference, but update your build hook to match any change in location.

    Final Build Hook:

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
        echo 'eval $(/app/.linuxbrew/bin/brew shellenv)' >>~/.profile
        eval $(/app/.linuxbrew/bin/brew shellenv)
        brew analytics off
        brew install gcc
        brew install openssl
        brew install freetds
        brew install unixodbc
        odbcinst -i -d -f /app/.odbc.ini
        pipenv install --system --deploy
        mkdir .ssh
    

    .odbc.ini

    [FreeTDS]
    Description	= TDS driver (Sybase/MS SQL)
    Driver		= /app/.linuxbrew/lib/libtdsodbc.so
    
    0

Please sign in to leave a comment.