SQLServerã§ã¤ãªã’ã¦ã¿ã‚‹
require 'rubygems' require 'sequel' require 'pp' # 接続パラメータã®æº–å‚™ params = {} # ADOè¨å®š params[:adapter] = "ado" params[:provider] = 'SQLOLEDB' params[:driver] = 'SQL Server' #接続è¨å®š params[:host] = "localhost" params[:database] = "#接続DBå#" params[:user] = '#接続ユーザー#' params[:password] = '#接続ユーザーパスワード#' #コãƒã‚¯ã‚·ãƒ§ãƒ³ãƒ—ールè¨å®š params[:max_connections] = 10 params[:pool_timeout] = 10 # 接続 db = Sequel.connect(params) # SQL実行 db['select * from muser'].each{|r| pp r} # ãƒã‚¤ãƒ³ãƒ‰æ–‡å—列を使用 ds = db[:muser] pp ds.filter('id like ?' , 'hoge%').all
※シンボルã§ãƒ†ãƒ¼ãƒ–ルåを指定ã™ã‚‹å ´åˆã¯ã€DBを作æˆã™ã‚‹æ™‚ã®ç…§åˆé †åºã‚’大文å—å°æ–‡å—を区別ã—ãªã„ã«è¨å®šã™ã‚‹å¿…è¦ãŒã‚ã‚‹ï¼ï¼ï¼
↓
SequelãŒSQLを生æˆã™ã‚‹éš›ã€:muserãªã‚‰MUSERã«æ›¸ãæ›ãˆã¦ã—ã¾ã†ç‚ºï¼ï¼ï¼
↓
パッãƒã‚ã¦ã‚‹ï¼Ÿï¼Ÿï¼Ÿ
※SQLã§DataSetを作æˆã™ã‚‹å ´åˆã€filterã«ã‚ˆã‚‹Bindæ–‡å—指定ãŒå‡ºæ¥ãªã‹ã£ãŸï¼ï¼ï¼