Setting up unixodbc and freetds on OSX and Rails 2.3.x
I'm trying to set up unixodbc on OSX (10.7.3) but it looks like iODBC is already on the way.
My config / database.yml:
development:
adapter: sqlserver
encoding: UTF8
mode: odbc
username: user
password: passwd
dsn: MY_DSN
ruby-obdc is installed and in Gemfile:
gem 'ruby-odbc', :require => 'odbc_utf8'
/usr/local/etc/freetds.conf:
[MY_SERVER] host = host.bla.com port = 1433 tds version = 8.0 client charset = UTF-8
/usr/local/etc/odbc.ini
[MY_DSN]
Driver=/usr/local/lib/libtdsodbc.so
Description=Sql Server Local
Servername=MY_SERVER
Port=1433
Database=my_database
When I run script/console
and try to access any model:
ODBC Product :: Error: IM002 (0) [iODBC] [Driver Manager] Data source name not found and no default driver specified. The driver could not be loaded
It seems that iODBC is used to connect to the database when I want to use unixodbc. How do I force my rails app to use unixodbc instead of iODBC?
source to share
iODBC, maintained and supported by my employer , shipped as part of Mac OS X with Jaguar (10.2.x).
You'd be better off updating iODBC with all the latest fixes (Apple tends to be a little behind them) than moving to UnixODBC. You can also find some benefit in Ruby + ODBC and Ruby-on-Rails that we have posted.
Finally, it is best to keep all ODBC configuration in the default files for Mac OS X -
/Library/ODBC/odbc.ini
/Library/ODBC/odbcinst.ini
/Users/*/Library/ODBC/odbc.ini
/Users/*/Library/ODBC/odbcinst.ini
You can create symlinks from anywhere you want these files, eg. -
ln -s ~/Library/ODBC/odbc.ini ~/.odbc.ini
source to share
Using Homebrew. Nessesary to use:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/unixodbc/2.3.2
I hadn’t noticed this before, but in Pedro I answered that he had with-odbc-lib
. not sure if this works for his environment, but I needed it to be dir
because I kept checking sql.h ... no error.
source to share