Skip to content

Instantly share code, notes, and snippets.

require 'dbi'
require 'dbd_odbc_patch'
dbh = DBI.connect("dbi:ODBC:DRIVER=FreeTDS;SERVERNAME=dbservername;DATABASE=MyDBName", "username", "password")
sth = dbh.prepare("select 1")
sth.execute
while row=sth.fetch do
p row
end
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/lib/libtdsodbc.so.0
Setup = /usr/lib/libtdsodbc.so.0
UsageCount = 1
@chadj
chadj / dbd_odbc_patch.rb
Created March 5, 2009 15:46
A monkey patch to fix how DBD::ODBC passes credentials to underlying DB driver
#
# Monkey patch DBD::ODBC to pass usernames and passwords along
# to the DB driver correctly
#
# Are you running a new version of DBI?
begin
require 'dbd/ODBC'
rescue Exception
end