Reputation: 821
I'm trying to write a python app (python 3.5 with pyCharm IDE) that put multiple queries and do math etc... It needs to run on both mac and windows. On windows side because of pymssql won't work i tried pyodbc which worked flawlessly (it's the opposite on mac side). But on the mac side whenever i try to connect with this code:
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=myServerIp;DATABASE=myDatabaseName;UID=myUserName;PWD=myPassword')
cursor = cnxn.cursor()
it gives the error of: pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'odbc.ini' : file not found (0) (SQLDriverConnect)")
Normally i can connect MS SQL from excel or any other query software on mac. I'm using Actual SQL Server driver on system wide.
So please guide me to fix this problem either using Actual SQL Server drivers (which is paid version) or properly configure python or unixodbc (not sure which is the problem). Thank you and regards
PS: I installed both pyodbc, unixodbc and freetds via pip as i followed documentation
Update1:
$ cat $(odbc_config --odbcinstini)
[ODBC]
DEBUG=1
TraceFile=/home/ftp/sqltrace.log
Trace=Yes
[FreeTDS]
Description=MSSQL Driver
Driver=/usr/local/lib/libtdsodbc.so
$ odbc_config --ulen
-DSIZEOF_SQLULEN=8
$ odbc_config --libs
-L/usr/local/Cellar/unixodbc/2.3.2_1/lib -lodbc
$ odbc_config --prefix
/usr/local/Cellar/unixodbc/2.3.2_1
$ odbc_config --odbcinstini
/usr/local/Cellar/unixodbc/2.3.2_1/etc/odbcinst.ini
$ odbc_config --odbcini
/usr/local/Cellar/unixodbc/2.3.2_1/etc/odbc.ini
$ odbc_config --version
2.3.2
Upvotes: 2
Views: 1638
Reputation: 821
uninstalling and installing again with this command fixed the issue:
brew install freetds --with-unixodbc
Upvotes: 2