后续示例将无法运行
我刚刚为 Ruby 安装了“sequel”gem。我想尝试 Sequel 网站上的示例,但它不起作用:( 测试.rb:
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite # memory database
DB.create_table :items do
primary_key :id
String :name
Float :price
end
items = DB[:items] # Create a dataset
# 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 test.rb
Error: ArgumentError: syntax error on line 11, col 37: `i'/usr/lib/ruby/1.8/yaml.rb:133:in `load'
I've just installed "sequel" gem for Ruby. I wanted to try example from Sequel website and it won't work :(
test.rb:
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite # memory database
DB.create_table :items do
primary_key :id
String :name
Float :price
end
items = DB[:items] # Create a dataset
# 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)}"
Console:
$ sequel test.rb
Error: ArgumentError: syntax error on line 11, col 37: `i'/usr/lib/ruby/1.8/yaml.rb:133:in `load'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
ruby
而不是sequel
来运行它You need to run this with
ruby
notsequel