Created
June 17, 2010 21:34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are VERY basic instructions for getting MS SQL Server working via ODBC on Mac OSX Snow Leopard, with rails. It assumes you know how to make / install libraries from source. It took a LOT of trial and error so your results may vary. | |
1. Install unixODBC | |
Get from http://www.unixodbc.org | |
./configure --prefix=/usr/local --enable-gui=no | |
make | |
sudo make install | |
2. Install FreeTDS | |
Get from http://www.freetds.org/ | |
Notice that you are configuring it to point to the location you specified above, where you installed unixODBC, and using the tds version 8.0 so that it works with the latest MS SQL Server. | |
./configure --prefix=/usr/local --with-tdsver=8.0 --with-unixodbc=/usr/local | |
make | |
sudo make install | |
3. Test TSQL | |
Make sure that tsql is installed correctly. | |
tsql -C | |
You should see it compiled with unixODBC, if not or if it shows you compiled with iODBC, sudo make uninstall both packages and try again. | |
4. Set up config files in /usr/local/etc | |
freetds.conf | |
[NAME_HERE] | |
host = [SERVER NAME / IP] | |
port = 1433 | |
tds version = 8.0 | |
odbcinst.ini | |
[FreeTDS] | |
Driver = /usr/local/lib/libtdsodbc.so | |
*note: verify that the .so is in the location above. If you configured as I showed, then you should be fine. | |
odbc.ini | |
[DSN_NAME] | |
Driver = FreeTDS | |
Server = [SERVER] | |
Database = [DATABASE] // optional, you might want to specify your database in your yml. | |
Port = 1433 | |
TDS_Version = 8.0 | |
5. Test with iSQL | |
isql is installed with unixODBC. You can use it to make sure the DSN is setup properly. After you launch isql, you should be able to send sql commands to the server and see results. | |
isql [DSN_NAME] [username] [password] | |
If this doesn't work, but tsql -C was correct, then check your config files and make sure you can really get to your server via TCP/IP. | |
6. Set up Ruby ODBC to work with unixODBC | |
Get Ruby ODBC here: http://www.ch-werner.de/rubyodbc/ | |
Configure with ruby config pointing to the usr/local directory. | |
ruby ext/extconf.rb --with-odbc-lib=/usr/local | |
make | |
sudo make install | |
In my experience, don't use the gem ruby-odbc. This isn't compiled to use unixODBC. | |
7. Install activerecord-sqlserver-adapter | |
gem install activerecord-sqlserver-adapter | |
I'm using version 2.3.8 which doesn't require the dbi or dbd-odbc gems. | |
After this you should test your rails app with a rake db:migrate or other methods to see if your server gets set up properly. | |
email vulgrin@gmail.com if you have any questions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment