Sequel 0.0.9 - Concise ORM for Ruby

Discussion in 'Ruby' started by Sharon Rosner, Mar 26, 2007.

  1. Sequel is a new ORM tool for Ruby. Sequel provides the following
    features:

    * Thread safety and connection pooling. You can write multi-threaded
    applications that connect to databases without worrying about handling
    connections.
    * A concise, chainable query DSL lets you stay close to the metal
    without writing SQL. You don't have to define model classes.
    * Datasets support filtering, ordering, summarizing, and joining.
    * Records are fetched one at a time, so you can work with huge result
    sets.
    * Currently has adapters for Postgresql, SQLite and MySQL (preliminary
    support).
    * Model classes work in similar fashion to ActiveRecord (but are
    currently missing some functionality.)

    RDoc documentation is here: http://sequel.rubyforge.org
    The source code is here: http://ruby-sequel.googlecode.com/svn/trunk

    A Short Example:

    require 'sequel/sqlite'

    # open an in-memory SQLite database
    DB = Sequel.open 'sqlite:/:memory:'

    # create a table
    DB.create_table :items do
    primary_key :id, :integer, :auto_increment => true
    column :name, :text
    column :price, :float
    end

    # popuplate table
    100.times {DB[:items] << {:name => "product#{rand(1000)}", :price =>
    rand * 100}}

    # create a dataset of highest priced products with a price over 70
    expensive_stuff = DB[:items].filter('price >
    70').reverse_order:)price).limit(10)

    puts "There are #{expensive_stuff.count} expensive items."

    puts "Most expensive items (in descending order)"
    expensive_stuff.each {|i| puts "#{i[:name]} = #{i[:price]}"}

    # print average of most expensive products
    puts "Average of expensive stuff: #{expensive_stuff.avg:)price)}"

    ------------------------------

    Sequel is in an early stage of development, so some things might be
    broken. I appreciate any comments as well as bug reports. Enojy!
     
    Sharon Rosner, Mar 26, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    13
    Views:
    801
    darrel
    Mar 30, 2006
  2. Frohnhofer, James

    Concise idiom to initialize dictionaries

    Frohnhofer, James, Nov 9, 2004, in forum: Python
    Replies:
    8
    Views:
    340
    Caleb Hattingh
    Nov 12, 2004
  3. Curt Hibbs

    A concise description of Ruby?

    Curt Hibbs, Oct 20, 2004, in forum: Ruby
    Replies:
    89
    Views:
    855
    bruno modulix
    Nov 4, 2004
  4. Sharon Rosner
    Replies:
    0
    Views:
    152
    Sharon Rosner
    Apr 16, 2007
  5. flebber
    Replies:
    3
    Views:
    288
    flebber
    Aug 14, 2009
Loading...

Share This Page