# Ruby odbc

**URL:** <https://www.ruby-forum.com/t/ruby-odbc/108347>\
**Category:** Ruby\
**Created:** [July 2, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/ruby-odbc/108347 "2007-07-02T16:40:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![donv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@donv](https://www.ruby-forum.com/u/donv)\
**Post date:** [July 2, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/ruby-odbc/108347/1 "2007-07-02T16:40:59Z")

</div>

Hi all!

I am trying to use ActiveRecord migrations from Linux on an MS SQL  
Server database running on windows. I am following the instructions  
given in

[http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnLinux](http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnLinux)

I have successfully set up freetds and unixODBC, and I can connect fine  
using tsql and isql.

When I try connecting using ruby I get the following:

[root@pippin laptop\_scripts]# irb  
irb(main):001:0\> require ‘odbc’  
=\> true  
irb(main):002:0\> require ‘dbi’  
=\> true  
irb(main):003:0\> dbh = DBI.connect(‘dbi:ODBC:database\_name’, ‘username’,  
‘password’)  
NoMethodError: undefined method `default_attributes' for #<ODBC::Driver:0xb7f6ade4 @attrs={}, @name=nil> from /usr/lib/ruby/site_ruby/1.8/dbi.rb:420:in `connect’  
from /usr/lib/ruby/site\_ruby/1.8/dbi.rb:215:in `connect’  
from (irb):3  
irb(main):004:0\>

Checking the ruby odbc documentation, the default\_attributes method is  
not defined, and the Driver class inherits from Object.

dbi.rb also tries to call a “connect” method on the Driver class, but  
“connect” is only defined on the ODBC module, not the Driver class.

What do I need to do to be able to connect? Any help is greatly  
appreciated.

Uwe
