Skip to content

Instantly share code, notes, and snippets.

@rubypanther
Created June 15, 2014 09:36
Show Gist options
  • Save rubypanther/670081512f45b4a285f6 to your computer and use it in GitHub Desktop.
Save rubypanther/670081512f45b4a285f6 to your computer and use it in GitHub Desktop.
MS Sql Server
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
Bundler.require(:db)
ActiveRecord::Base.establish_connection YAML.load_file( File.join(File.dirname(__FILE__),'..','config','database.yml'))[environment]
$: << File.join(File.dirname(__FILE__),'..','app','models' )
# do work here
development:
adapter: sqlserver
mode: odbc
dsn: blah-blah-blah
username: blahblah
password: blahblah
encoding: utf8
group :db do
gem 'ruby-odbc', :require => 'odbc'
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter', '~> 3.1.0'
end
group :development do
gem 'rails'
end
[blah-blah-blah]
Description = This is the dsn you cite from database.yml
Driver = ms-sql
Servername = WINDOWSNETWORKNAMEOFSERVER
UID = Home
Port = 1433
Database = the_real_db_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment