Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2011 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/910989 to your computer and use it in GitHub Desktop.
Save anonymous/910989 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 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