Digital Drip - The Tech Blog of Jon Gaudette
Blog  /  Setting up FreeTDS against Sybase with Ruby
Tux

Setting up FreeTDS against Sybase with Ruby

Posted on: October 25, 2010

Connecting to Sybase from within Linux is not as easy as, say, connecting to PostgreSQL or MySQL, but if you know the steps involved it can be rather painless. To connect we are going to use the FreeTDS project and ODBC.

Configuring the FreeTDS Client

First step is to install the freetds package.
Arch Linux: pacman -Sy freetds
Debian Linux: apt-get install freetds-common

Next, setup your /etc/freetds/freetds.conf. In this example, our alias is “PROD

We can now test freetds with the included sqsh program:
sqsh -S PROD -U <username> -P <password>

Configuring UNIX ODBC Connections

Once successful with FreeTDS, we now will configure unix ODBC to work with it. This will let us use a plethora of tools and languages to interact with our database, including ruby.

Arch Linux: pacman -Sy unixodbc
Debian Linux: apt-get install unixodbc

/etc/odbcinst.ini

/etc/odbc.ini

We can now test with isql. This program can also be used to run sql scripts, for example via cron. This is a great way to run miscellaneous reports and queries.
isql -v qual1 <username> <password>

Configuring Ruby

gem install dbi
gem install dbd-odbc
gem install ruby-odbc

Simple test script

Comments are Disabled