我的 Ruby 程序只是想调用一个存储过程(它将进行一些计算)并返回一个我想使用 Ruby 代码通过电子邮件发送的结果集。请注意,我没有使用 Rails,只是使用普通的 Ruby 和 mysql2 gems。
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:host => "localhost",
:database => "<mydb>",
:username => "<myusername>",
:password => "<mypassword>"
)
class Rubyist < ActiveRecord::Base
end
rubyist = Rubyist.new
puts rubyist.connection.execute("CALL ruby_routine")
返回以下错误
Mysql2::Error: PROCEDURE students.ruby_routine can't return a result set in the given context: CALL ruby_routine (ActiveRecord::StatementInvalid)
现在我用谷歌搜索了这个并找到了链接,但它们是针对 Rails 应用程序的。我如何在纯 Ruby 中做到这一点?