iODBC does not work under Mac OSX 10.6.4

末鹿安然 提交于 2019-12-08 01:24:27

问题


I've installed iODBC over the package (http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/) and set up all config files as described here: http://blog.opensteam.net/past/2009/1/28/rails_ms_sql_on_mac/

I set up the same thing on a Linux machine and it worked fine. On my Mac OSX 10.6.4, I get this error if i test the connection:

xxx@xxx:/opt/local/include$ iodbctest "dsn=res;uid=user;pwd=pass"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/opt/local/lib/libtdsodbc.so, 6): Symbol not found: _CreateDataSource
Referenced from: /usr/lib/libiodbcinst.2.dylib
Expected in: flat namespace
(0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003

I have no idea how to debug this :(


回答1:


It would be interesting to see what params you have in your odbc.ini and odbcinst.ini files for the DSN and FreeTDS driver being used ?

Looks as if the Apple iODBC Driver Manager is not able to load setup routines required for the driver nor does the FreeTDS driver itself.

The OpenLink iODBC Driver Manager for Mac OS X (which Apples bundled one is based on) is Framework based and does include routines for loading generic setup and login dialogs for those ODBC drivers that do not have built in one. You can download it free (as it is open source) from the following location:

http://www.iodbc.org/downloads/iODBC/iodbc-sdk-3.52.7-macosx-10.5.dmg (it is for 10.5 and 10.6)




回答2:


Steps to follow:

  1. brew install freetds

  2. subl ~/Library/ODBC/odbc.ini

  3. [sqlserver01]
    Driver=/usr/local/lib/libtdsodbc.so
    TDS_Version=7.2
    Server=192.168.8.7
    Port = 1433
    Trace = Yes
    Description=ds01
    # Database=
    # can't specify username and password for freetds

  4. subl ~/.freetds.conf

  5. host = ds01.uswa.net # server name
    port = 1433
    tds version = 8.0 # works with 2008+

  6. sudo pip install pyodbc sudo pip install sqlsoup

The Python Connection String would look like this:

# Steve is my username; steve is my password; #sqlserver01 is my DSN in odbc.ini
db = sqlsoup.SQLSoup('mssql+pyodbc://Steve:steve@sqlserver01')

The SQLAlchemy way would look like this:

engine = create_engine('mssql+pyodbc://Steve:steve@sqlserver01')`

Do whatever queries…




回答3:


I had the same problem, linux works, Lion 10.7 not (I guess same problem for 10.6). I'm using FreeTDS driver to connect, compiling from the source code: it looks like that when compiling, libtdsodbc.so is compiled for the wrong architecture or 32bit/64bit.

I followed this guide (excluding Excel part), and everything worked like a charm. http://asmiler.blogspot.fr/2011/10/accessing-mssql-databases-from-excel.html



来源:https://stackoverflow.com/questions/3905093/iodbc-does-not-work-under-mac-osx-10-6-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!