require 'mysql2'
SCHEDULER.every '2h', :first_in => 0 do |job|
# MySQL connection
db = Mysql2::Client.new(:host => "host", :username => "username", :password => "password", :port => port, :database => "database" )
sql = "select count(*) from tickets where department_id = 6;"
tickets_sql = db.query(sql)
puts tickets_sql
#Send Events
send_event('tickets_sql', {current: tickets_sql})
end
我正在使用该puts
命令,所以我可以在我的日志文件中看到输出。此命令的输出是一条错误消息,即:#<Mysql2::Result:0x000000025546a8>
这个错误是什么意思?
我采用与代码中相同的确切查询并在数据库上运行它并按预期输出数字。