# Mac OS Rails =\> SQL Server

**URL:** <https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883>\
**Category:** Rails\
**Created:** [November 14, 2005, 9:14pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883 "2005-11-14T21:14:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 9:14pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/1 "2005-11-14T21:14:06Z")

</div>

I am about to start developing a Rails on my Mac for a client. The  
app is connecting to a legacy system that uses SQL Server. Should I  
follow the instructions at  
[http://wiki.rubyonrails.com/rails/pages/](http://wiki.rubyonrails.com/rails/pages/)  
HowtoConnectToMicrosoftSQLServerFromRailsOnLinux

or, does anyone have Mac OS-specific instructions?

Thanks,

Jamie O-H

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 9:41pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/2 "2005-11-14T21:41:10Z")

</div>

Hello,  
I think your best option would be to use this odbc driver,  
[http://www.actualtechnologies.com/](http://www.actualtechnologies.com/). The full version is $29.95 and  
they also have a demo you can download and test.

Then setup your database.yml like this:  
development:  
adapter: sqlserver  
mode: odbc  
dsn: YOUR\_DB\_DEFINITION\_NAME  
username: USERNAME  
password: PASSWORD

–  
Joe C.

> **[RailsPlayground.com Ruby On Rails Hosting](https://railsplayground.com/)**
>
> Ruby on Rails Web Hosting starting at just $5/a month

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 9:56pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/3 "2005-11-14T21:56:12Z")

</div>

That would probably be the best thing to do. If you’re _adamant_ about  
not paying a dime and don’t mind screwing things up a few times, my G5  
dev setup at work involves using FreeTDS and the supplied IODBC layer.  
You’ll need to use the SQLServer adapter that Tom W. has been  
working on, in ODBC mode. I also can’t get the connection working with  
a full DSN, so I have ODBC “short DSNs” set up for each server i need  
to connect to.

I’ll post my own notes tomorrow when I’m back at work.

- james

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 10:02pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/4 "2005-11-14T22:02:20Z")

</div>

Thanks James and Joe. I am just starting down the Darwin Ports path  
of installing this stuff, but may divert over to the actual  
technologies driver and test it out. I’d found it on a search, but  
ignored it because of the cost.

Jamie

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 10:11pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/5 "2005-11-14T22:11:22Z")

</div>

Jamie - just a note, I had to convert the latest FreeTDS package (0.63  
at the time I think) into a dports package and install it, rather than  
use the existing darwin ports version… things might be better now,  
it was a few months ago.

Anyway - best of luck!

- james

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 10:47pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/6 "2005-11-14T22:47:27Z")

</div>

Thanks. You guys have convinced me to look at the Actual stuff.

Jamie

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 14, 2005, 10:14pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/7 "2005-11-14T22:14:22Z")

</div>

I messed around for hours trying to get the freeTDS drivers to work  
correctly under Mac OS X and I finally gave in and bought the driver  
from Actual Technologies, which is very easy to setup. This was  
several months ago, so maybe the freeTDS drivers are easier now.

James, I would be interested in hearing how you did your setup.

–  
Joe C.

> **[RailsPlayground.com Ruby On Rails Hosting](https://railsplayground.com/)**
>
> Ruby on Rails Web Hosting starting at just $5/a month

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 15, 2005, 11:53pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/8 "2005-11-15T23:53:34Z")

</div>

James and Joe:

Have either of you successfully used the Actual driver successfully  
with DBI? I thought I’d try that before Rails, but I keep getting  
errors and am wondering if I’ve missed a step.

irb(main):004:0\> dbh = DBI.connect  
(‘DBI:ODBC=thedb’,‘Login’,‘somePassword’)  
TypeError: is not a class/module  
from /opt/local/lib/ruby/vendor\_ruby/1.8/dbi/dbi.rb:499:in  
`load_driver' from /opt/local/lib/ruby/vendor_ruby/1.8/dbi/dbi.rb:401:in`\_get\_full\_driver’  
from /opt/local/lib/ruby/vendor\_ruby/1.8/dbi/dbi.rb:381:in  
`connect’  
from (irb):4

Thanks,

Jamie

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 16, 2005, 8:40am UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/9 "2005-11-16T08:40:51Z")

</div>

jamie wrote:

> I am about to start developing a Rails on my Mac for a client. The  
> app is connecting to a legacy system that uses SQL Server. Should I  
> follow the instructions at  
> [Peak Obsession](http://wiki.rubyonrails.com/rails/pages/)  
> HowtoConnectToMicrosoftSQLServerFromRailsOnLinux
> 
> or, does anyone have Mac OS-specific instructions?
> 
> Thanks,
> 
> Jamie O-H

oops!

---

<div class="post-metadata">

**Author:** ![jamie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aca169/32.png) [@jamie](https://www.ruby-forum.com/u/jamie)\
**Post date:** [November 16, 2005, 12:24pm UTC](https://www.ruby-forum.com/t/mac-os-rails-sql-server/47883/10 "2005-11-16T12:24:00Z")

</div>

## Here follows a huge copy-paste of my FreeTDS/iodbc/SQLServer notes:

FREETDS

Get yourself the latest build of FreeTDS (0.63 as of writing this),  
and build it like so:

cd /usr/local/src  
curl -O  
ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz  
tar zxvf freetds-stable.tgz  
cd freetds-0.63  
./configure

At this point, we need to hack the generated libtool. Somewhere around  
line 205 you should see:

archive\_cmds="$CC $(if test .$module = .yes; then echo -bundle;  
else echo -dynamiclib; fi) $allow\_undefined\_flag -o $lib $libobjs  
$deplibs $linkopts -install\_name $rpath/$soname $verstring"

Basically you need to remove the $deplibs in that line.

make  
sudo make install

You can now test this by trying to connect to an MS SQL Server. To do  
this, we’re using the tsql tool that is compiled along with FreeTDS:

$ tsql -H 10.9.0.95 -p 1147 -U sa  
locale is “C”  
locale charset is “US-ASCII”  
Password:  
1\> use northwind  
2\> go  
1\> select count (\*) as “Num” from customers  
2\> go  
Num  
91  
1\> exit

## ODBC Administrator

ODBC Administrator

created by James A.

Firstly, add the driver under the “Drivers” tab.

Then you almost certainly want to create a User DSN, with the parameters

```
* Server e.g. localhost
* Database e.g. Northwind
* UID e.g. Administrator
* PWD
* Port e.g. 1147

```

This data gets stored in ~/Library/ODBC/odbc.ini. Any problems, you  
can hack at that.

An entry should look like this:

[Redcats]  
Driver = /opt/local/lib/libtdsodbc.so  
Description = Redcats Development Database  
Server = 10.9.0.95  
Host = localhost\TESTSQL2  
Port = 1147  
Database = redcats\_dev  
UID =   
PWD =   
TDS\_Version = 8.0

I’m not sure if you need to keep the ~/.freetds.conf in sync or not,  
but i tend to. You need an entry to correspond with each ODBC entry:

[global]  
tds version = 8.0

[Redcats]  
host = GBLON1SQM27  
port = 1147

… might be useful.

- james
