Sequel 介绍
Sequel 是一个 Ruby 语言的对象映射框架(ORM),提供了线程安全、连接池以及 DSL 语言用来构造查询和表模型。
示例代码:
require "rubygems" require "sequel" # connect to an in-memory database DB = Sequel.sqlite # create an items table DB.create_table :items do primary_key :id String :name Float :price end # create a dataset from the items table items = DB[:items] # populate the table items.insert(:name => 'abc', :price => rand * 100) items.insert(:name => 'def', :price => rand * 100) items.insert(:name => 'ghi', :price => rand * 100) # print out the number of records puts "Item count: #{items.count}" # print out the average price puts "The average price is: #{items.avg(:price)}"
Sequel 官网
http://sequel.jeremyevans.net/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。