Forum: Ruby on Rails Mac OS Rails => SQL Server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7a966bb1534f0ea863bc9ffe65ae449f?d=identicon&s=25 jamie (Guest)
on 2005-11-14 21:14
(Received via mailing list)
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/
HowtoConnectToMicrosoftSQLServerFromRailsOnLinux

or, does anyone have Mac OS-specific instructions?

Thanks,

Jamie O-H
3d7e63cfdded1786a6526f52478e6ea6?d=identicon&s=25 joemclarke (Guest)
on 2005-11-14 21:41
(Received via mailing list)
Hello,
  I think your best option would be to use this odbc driver,
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 Clarke
http://railsplayground.com
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 21:56
(Received via mailing list)
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 Ward 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
7a966bb1534f0ea863bc9ffe65ae449f?d=identicon&s=25 jamie (Guest)
on 2005-11-14 22:02
(Received via mailing list)
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
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-14 22:11
(Received via mailing list)
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
3d7e63cfdded1786a6526f52478e6ea6?d=identicon&s=25 joemclarke (Guest)
on 2005-11-14 22:14
(Received via mailing list)
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 Clarke
http://railsplayground.com
7a966bb1534f0ea863bc9ffe65ae449f?d=identicon&s=25 jamie (Guest)
on 2005-11-14 22:47
(Received via mailing list)
Thanks. You guys have convinced me to look at the Actual stuff.

Jamie
7a966bb1534f0ea863bc9ffe65ae449f?d=identicon&s=25 jamie (Guest)
on 2005-11-15 23:53
(Received via mailing list)
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
D41d8cd98f00b204e9800998ecf8427e?d=identicon&s=25 Guest (Guest)
on 2005-11-16 08:40
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
> http://wiki.rubyonrails.com/rails/pages/
> HowtoConnectToMicrosoftSQLServerFromRailsOnLinux
>
> or, does anyone have Mac OS-specific instructions?
>
> Thanks,
>
> Jamie O-H

oops!
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-16 12:24
(Received via mailing list)
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 Adam

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         = <username>
PWD         = <password>
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
This topic is locked and can not be replied to.