Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Created September 17, 2014 19:08
Show Gist options
  • Save campanalbero/121aa020f50a307a2b50 to your computer and use it in GitHub Desktop.
Save campanalbero/121aa020f50a307a2b50 to your computer and use it in GitHub Desktop.
sequel で where 句の書き方
require 'rubygems'
require 'sequel'
require 'pp'
DB = Sequel.sqlite('photo.db')
dataset = DB[:photos]
# どちらでも同じ
# select * from photos where model = 'NIKON D40';
pp dataset.filter(:model => 'NIKON D40').first
pp dataset.where{"model = 'NIKON D40'"}.first
# select date_time_original from photos where model = 'NIKON D40';
pp dataset.filter(:model => 'NIKON D40').first[:date_time_original]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment