Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to mssql from sqlalchemy by pyodbc on mac os

Anyone has successfully connect to mssql thru pyodbc within sqlalchemy? I am using turbogears2 right now, and try to connect to mssql, working on a mac os platform.

Getting following error:

sqlalchemy.exc.DBAPIError: (Error) ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (0) (SQLDriverConnectW)') None None
like image 280
Leon Guan Avatar asked Jan 12 '11 03:01

Leon Guan


2 Answers

There is a better approach than the old macports or fink, brew:

brew install freetds unixodbc

And it doesn't even need root to install it.

like image 195
sorin Avatar answered Sep 30 '22 08:09

sorin


Easy way by MacPort

Simply do the installation by:

    sudo port install freetds +mssql +odbc +universal

This will install both freetds and unixODBC, we can either using unixODBC for ODBC management, or using iODBC shipped with Mac OS.

Compile and installation

    ./configure --prefix=/usr/local/lib/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
    make
    make install

TDSVER setting

For connecting to SQL Server 2005/8, make sure setting the tds version to 8.0, use following terminal command:

    export TDSVER = 8.0

Lauguange setting

Make sure right language has been setted:

    export LC_ALL=en_US.UTF-8
like image 40
Leon Guan Avatar answered Sep 30 '22 09:09

Leon Guan