Skip to content

Instantly share code, notes, and snippets.

@danielwestendorf
Created April 9, 2011 00:48
Show Gist options
  • Save danielwestendorf/910985 to your computer and use it in GitHub Desktop.
Save danielwestendorf/910985 to your computer and use it in GitHub Desktop.
MacRuby 0.10 + Sequel
require 'rubygems'
require 'sqlite3'
require 'sequel'
DB = Sequel.sqlite()
DB.create_table :entries do
primary_key :id
String :words
end
DB[:entries].insert(:words => "Hello MacRuby!")
puts "Querying for all entries records: #{DB[:entries].all.to_s}"
puts "Query for just the first record: #{DB[:entries].first}"
puts "Query for record based on words: #{DB[:entries].where(:words => "Hello MacRuby!")}"
#RESULT#
$macruby database.rb
Querying for all entries records: [{:id=>1, :words=>"Hello MacRuby!"}]
Query for just the first record:
Query for record based on id:
rvm use 1.9.2
$ruby database.rb
Querying for all entries records: [{:id=>1, :words=>"Hello MacRuby!"}]
Query for just the first record: {:id=>1, :words=>"Hello MacRuby!"}
Query for record based on id: {:id=>1, :words=>"Hello MacRuby!"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment