可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
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
回答3:
Steps to follow:
brew install freetds
subl ~/Library/ODBC/odbc.ini
[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
subl ~/.freetds.conf
host = ds01.uswa.net # server name
port = 1433
tds version = 8.0 # works with 2008+
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…