MS SQL Server connection via Ruby

I am running Ruby on Fedora Core 6 and I am running into problems I do
not see on my windows box. Any help would be awesome - its been 2 days
I tried everything and even installed unixODBC and that worked but
installing freeTDS ha problems. Can someone guide me into getting this
to work?

def test_connection
begin
connect( “DBI:ODBC:Driver={SQL
Server};Server=#{@adapter_config[“acct_db_host”]};Database=#{@adapter_config[“acct_db_name”]};Uid=#{@adapter_config[“acct_db_user”]};Pwd=#{@adapter_config[“acct_db_pass”]}”
)
is_connected
rescue DBI::DatabaseError => e
puts “Error #{e.errstr}”
rollback
ensure
#disconnect from server
disconnect
end
end

/usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:511:in load_driver': Could not load driver (no such file to load -- odbc) (DBI::InterfaceError) from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in_get_full_driver’
from /usr/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in connect' from ./database_adapter.rb:77:inconnect’
from ./database_adapter.rb:65:in test_connection' from ./game_adapter.rb:6:ininitialize’
from ./ballerium/ballerium_adapter.rb:6:in initialize' from ./game_adapter_factory.rb:14:innew’
from ./game_adapter_factory.rb:14:in `get_adapter’
from test.rb:11

David L. wrote:

I am running Ruby on Fedora Core 6 and I am running into problems I do
not see on my windows box. Any help would be awesome - its been 2 days
I tried everything and even installed unixODBC and that worked but
installing freeTDS ha problems. Can someone guide me into getting this
to work?

I was able to install freetds on ubuntu 7.04. This is my /tmp/odbc.ini
part.

[TESTSQL]
Driver = FreeTDS
Description = FreeTDS SQL Server ODBC driver
Server = testsql.my.com
Port = 1433
Database = ruby
User =
Password =
Mars_Connection = No
Logging = 0
LogFile =
QuotedId = Yes
AnsiNPW = Yes
Language =
Version7 = No
ClientLB = No
Failover_Partner =
VarMaxAsLong = No

And am using DBI odbc driver.

require ‘dbi’
dbs = DBI.connect(‘DBI:ODBC:TESTSQL’, ‘usr’, ‘pwd’)

It works with rails too, minus UTF-8 support. But that can be managed
too.

by
TheR