Is it possible to send data contained in postgres to dashing dashboard? I have found mysql example here and same question here.
I edited my job in jobs folder. I have also included pg gem.
require 'pg'
conn = PGconn.new(:host => "10.10.8.10", :port => "5432",:dbname => "db1",:login => "test",:password => "test")
results = conn.exec("select partner,sitetype from test")
# Sending to List widget, so map to :label and :value
acctitems = results.map do |row|
row = {
:label => row['partner'],
:value => row['sitetype']
}
end
# Update the List widget
send_event('account_count', { items: acctitems } )
end
Include in Gemfile :
gem 'pg'
In your jobs.rb file:
require 'pg'
SCHEDULER.every '3m', :first_in => 0 do |job|
conn = PGconn.new(:host => "localhost", :port => "5432",:dbname => "dbname",:user => "test",:password => "test")
results = conn.exec("select partner,sitetype from test")
# Sending to List widget, so map to :label and :value
acctitems = results.map do |row|
row = {
:label => row['partner'],
:value => row['sitetype']
}
end
# Update the List widget
send_event('account_count', { items: acctitems } )
end