MS SQL Server connection via Ruby

D

David Lee

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:in `connect'
from ./database_adapter.rb:65:in `test_connection'
from ./game_adapter.rb:6:in `initialize'
from ./ballerium/ballerium_adapter.rb:6:in `initialize'
from ./game_adapter_factory.rb:14:in `new'
from ./game_adapter_factory.rb:14:in `get_adapter'
from test.rb:11
 
D

Damjan Rems

David said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top