I am using dashing.io and want to grab some data from a mysql database using rufus scheduler to push them.
I have this code for testing the connection closing in one .rb job file:
require 'rubygems'
require 'mysql2'
SCHEDULER.every '12h', :first_in => 0 do |job|
begin
db = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "rainer-zufall", :port => 2971, :database => "test" )
open_connections = db.query("show status like 'Connections';")
open_connections.each do |row|
puts "connections: #{row}"
end
rescue
ensure
db.close
end
end
The database connection do not close. The connection counter still increases and soon there will be an error stating max_connections reached from the mysql-server.
Can anybody help?