Is SQL Server not supported in RoR on the Mac?

Hi,

You can’t use ADO on anything but Windows, as using ADO depends on win32ole. However, you should be able to find plenty of advice for connecting to SQL Server from OS X, Unix and Linux using ODBC. I haven’t done it myself, so I’ll leave it to you to search the group or Google or wait for replies from those with experience.

Regards,
Craig

Cheers, Craig -- what I was needing there was a little hope, and you
just provided it! I'll see what crops up here, and get searching.
Thanks again,
   Doug.

Doug Livesey wrote:

Cheers, Craig -- what I was needing there was a little hope, and you
just provided it! I'll see what crops up here, and get searching.
Thanks again,
   Doug.

I connect to SQL Server, from both a Mac, and a redhat box.

Been awhile since I wrote this, but it worked for the last person who
tried it.

How to get Ruby on Rails (unix / mac) to work with SQL Server

Thanks massively for that!
I guess I know what I'm gonna be doing for the next few days ... Tearing
my hair out!
Cheers, & I'll post how I get on (although don't hold your breath!).
   Doug.

Hi -- sorry if I'm being really dumb, but I'm rather an OSX & *nix
newbie.
I've been following your recommendations to the letter, and have got to
the Test 1 and Test 2 bit.
When I run these tests, I get the following:

<output>
etc 520 $ tsql -S aspect -U 'workgroups\dsmith' -P fakepassword -I
/etc/freetds.conf
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
There was a problem connecting to the server
etc 521 $ isql aspect 'workgroups/dsmith' 'fakepassword'
dyld: lazy symbol binding failed: Symbol not found: _tds_alloc_context
  Referenced from: /usr/local/lib/libtdsodbc.so
  Expected in: flat namespace

dyld: Symbol not found: _tds_alloc_context
  Referenced from: /usr/local/lib/libtdsodbc.so
  Expected in: flat namespace

Trace/BPT trap

</output>

I've tried understanding this from a number of perspectives, including
on my head & backwards through a mirror, but I'm afraid it's all Dutch
to me.
Does that output give you any hint of what I may have done wrong?
& thanks again,
   Doug.

I posted this about a year ago. See if that helps.

http://www.napcsweb.com/blog/2007/03/08/15/

I will do, Brian, thankyou!
If I can, I think I'll work through your article step-by-step (monkey
see, monkey do!), but that does raise one question -- is it possible my
earlier attempts to set this up will muck it all up?
Should I worry about cleaning out what I've done before?
Anyway, thanks again for everyone's input, & I'll let you know how I get
on.
Cheers,
   Doug.

Like I say -- I'll post how I do, but it's hometime, now -- it's 9
o'clock here in the UK, and Friday night to boot!
Thanks again,
   Doug.

Hi again, Brian -- it's been a while, as life got in the way again.
I'm following your instruction, which is great btw -- thanks for that.
I just have a couple of probably really dumb questions.
1) Where, in your instruction, you have 'MY_SERVER_NAME', I'm guessing
that should be swapped out for the name or IP address of the server
holding SQL Server?
2) Similarly, should 'MY_DATABASE_NAME' be swapped out for the actual
name of the database I'm connecting to?
3) Is 'MY_DSN' meant to be swapped out for something, and if so, what
would it be?

&, once again, I really appreciate you writing the article & drawing my
attention to it.

Cheers,
   Doug.

It appears that there's a problem with FreeTDS on OSX Leopard -- details
here:
http://article.gmane.org/gmane.comp.db.tds.freetds/8992

I'm still on with this problem, but will post when I get it sussed.
Cheers,
   Doug.

That makes sense, the guide I posted above has worked flawlessly 2
mac's, and 3 unix boxes.

The only system that's a problem is a Leopard system, (not mine).

I'm not to sure what to do about this though.
(I've actually switched to using a global virtual instance, to let all
of our developers work with, saves a ton of time when it comes to
installing this, and a dozen other applications we use.

Doug Livesey wrote:

Well that worked -- unfortunately I now have a new problem!
Probably due to my various efforts (including gem installing the SQL
Server adapter for ActiveRecord & copying the DBD/ado.rb file over), I
get FreeTDS working, but the following error output from my console in
Rails when I try to count on a model called Properties:

<CONSOLE>

Property.count

DBI::InterfaceError: Could not load driver (no such file to load --
/usr/local/lib/ruby/site_ruby/1.8/dbd/ADO)
  from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:368:in `load_driver'
  from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:233:in
`_get_full_driver'
  from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:219:in `connect'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0/lib/active_record/connection_adapters/sqlserver_adapter.rb:46:in
`sqlserver_connection'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in
`send'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in
`connection='
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in
`retrieve_connection'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1080:in
`columns'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/calculations.rb:254:in
`column_for'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/calculations.rb:118:in
`calculate'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/calculations.rb:46:in
`count'
  from (irb):2

</CONSOLE>

Can anyone maybe offer any advice from that? I'm stumped!
Cheers,
   Doug.

Doug, did you ever get that working? I have the same error as you.
I've gotten each step working and can connect to SQL Server through
the FreeTDS client, but can't through DBI.connect().

DBI::InterfaceError: Could not load driver (no such file to load -- /
Library/Ruby/Site/1.8/dbd/ODBC)
  from /Library/Ruby/Site/1.8/dbi.rb:368:in `load_driver'
  from /Library/Ruby/Site/1.8/dbi.rb:233:in `_get_full_driver'
  from /Library/Ruby/Site/1.8/dbi.rb:219:in `connect'
  from (irb):5

Andy wrote:

Doug, did you ever get that working? I have the same error as you.
I've gotten each step working and can connect to SQL Server through
the FreeTDS client, but can't through DBI.connect().

DBI::InterfaceError: Could not load driver (no such file to load -- /
Library/Ruby/Site/1.8/dbd/ODBC)
  from /Library/Ruby/Site/1.8/dbi.rb:368:in `load_driver'
  from /Library/Ruby/Site/1.8/dbi.rb:233:in `_get_full_driver'
  from /Library/Ruby/Site/1.8/dbi.rb:219:in `connect'
  from (irb):5

On Apr 11, 5:42�am, Doug Livesey <rails-mailing-l...@andreas-s.net>

You should have pathto/dbd/ODBC directory and odbc.rb file in it. I
dont't quite remember where I got it but I think you specify which
drivers to install when you install dbi package.

You may also look into dbi package and search for odbc.rb file end
extract it manualy into pathto/dbd/ODBC directory.

by
TheR

Hi!
Sorry, I didn't get it sorted at all -- I ran past my level of
expertise!
I'm sort of hoping that the next Ruby or Rails update will give me the
blank slate I need to get it working, and in the meantime I'm employing
horrible kludges you don't even want to hear about!
Sorry I'm not more help,
   Doug.

I ended up getting ActiveRecord on OS X talking to SQL Server after
lots of work and trial and error.

Here were a couple of my resources in addition to the Rails wiki
pages.

http://toolmantim.com/article/2007/5/7/getting_rails_talking_to_sqlserver_on_osx_via_odbc
http://www.easysoft.com/developer/languages/ruby/rails.html#installing-easysoft-odbc-sql-server-driver

The second is a commercial ODBC package priced per machine at 500
pounds as of this writing. I'm able to connect without that using
iODBC and FreeTDS.

Note that I also found the activerecord-sqlserver-adapter is no longer
on gems.rubyonrails.com and as of Rails 2 is no longer included with
the activerecord gem. So I found it on github and cloned that done,
prepared the .gem file and installed it that way. I didn't find
instructions for that, so I'm assuming it was just because it had
recently been moved to GitHub following Rails.

AndyAtkinson