Created
April 9, 2011 00:52
-
-
Save anonymous/910989 to your computer and use it in GitHub Desktop.
MacRuby 0.10 + Sequel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 id: #{DB[:entries].where(:id => 1).first.to_s}" | |
#results | |
$ 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