Topic: unixODBC and FreeTDS in ROR


I Installed freeTDS, uniODBC everything need for to connect the MSSQL server from ROR. I am able to connect the SQL server using isql command.
However, I am trying to connect the SQL server by the following line

@db = DBI.connect('dbi:ODBC:datasourcename', 'username', 'password')

In the line, I got the below error
Unable to load driver 'ODBC' (underlying error: uninitialized constant DBI::DBD::ODBC)

How can I solve this issue?

Otherwise please tell me if any other way (instead if freeTDS) we have to connect the SQL server from ROR ?

- Periyasamy

Last edited by Periyasamy (2011-11-24 10:39:18)

Re: unixODBC and FreeTDS in ROR

This post is kind of old so you probably already have this figured out, but...

If you have UnixODBC working and you have your SQL Server driver setup in odbcinst.ini something like this:

Description   = Sql Server driver
Driver    = /usr/lib/odbc/
Driver64    =
Setup   = /usr/lib/odbc/
Setup64   =
UsageCount    = 1
CPTimeout   =
CPReuse   =

... and your datasource set up in odbc.ini something like this:

Description   = SqlServer
Driver    = SqlServer
Servername    = your_server_name
Database    = your_database_name
UID   = your_username
PWD   = your_password
Port    = 1433

Then you should be able to set your connection in database.yml to something like this:

  adapter: sqlserver
  mode: odbc
  database: your_database_name
  username: your_username
  password: your_password