Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JFernandezWM/db0ea7e9880e14c31df3fd661bb24f00 to your computer and use it in GitHub Desktop.
Save JFernandezWM/db0ea7e9880e14c31df3fd661bb24f00 to your computer and use it in GitHub Desktop.
A sample script for connecting to MS SQL Server database using Sequel ORM with the TinyTDS adapter.

Ruby Sequel TinyTDS MS SQL Example

A sample script for connecting to MS SQL Server database using Sequel ORM with the TinyTDS (FreeTDS) adapter.

#!/usr/bin/env ruby

require 'sequel'
require 'tiny_tds'

db_connection_params = {
  :adapter => 'tinytds',
  :host => '127.0.0.1', # IP or hostname
  :port => '1434', # Required when using other that 1433 (default)
  :database => 'dbName',
  :user => 'dbUser',
  :password => 'P@$$worD'
}

DB = Sequel.connect(db_connection_params)

tbl = DB[:tblName]

dataset = tbl.all

dataset.each do |row|
  puts row.to_s
end

Additional Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment