Sequel: The Database Toolkit for Ruby
- Sequel provides thread safety, connection pooling and a concise DSL for constructing database queries and table schemas.
- Sequel also includes a lightweight but comprehensive ORM layer for mapping records to Ruby objects and handling associated records.
- Sequel supports advanced database features such as prepared statements, bound variables, stored procedures, master/slave configurations, and database sharding.
- Sequel makes it easy to deal with multiple records without having to break your teeth on SQL.
- Sequel currently has adapters for ADO, DataObjects, DB2, DBI, Firebird, Informix, JDBC, MySQL, ODBC, OpenBase, Oracle, PostgreSQL and SQLite3.
A short example:
require "rubygems"
require "sequel"
DB = Sequel.sqlite
DB.create_table :items do
primary_key :id
String :name
Float :price
end
items = DB[:items]
items.insert(:name => 'abc', :price => rand * 100)
items.insert(:name => 'def', :price => rand * 100)
items.insert(:name => 'ghi', :price => rand * 100)
puts "Item count: #{items.count}"
puts "The average price is: #{items.avg(:price)}"