-
Notifications
You must be signed in to change notification settings - Fork 323
How to: send mysql data to your widgets
pablo808 edited this page Sep 5, 2013
·
1 revision
Query Mysql then send to List widget
require 'mysql2'
SCHEDULER.every '15m', :first_in => 0 do |job|
# Myql connection
db = Mysql2::Client.new(:host => "192.168.1.1", :username => "dashing", :password => "SECRET", :port => 3306, :database => "users" )
# Mysql query
sql = "SELECT acct AS account, COUNT( acct ) AS count FROM users ORDER BY COUNT(*) DESC LIMIT 0 , 5"
# Execute the query
results = db.query(sql)
# Sending to List widget, so map to :label and :value
acctitems = results.map do |row|
row = {
:label => row['account'],
:value => row['count']
}
end
# Update the List widget
send_event('account_count', { items: acctitems } )
end
- Home
- Dashing Workshop
- Installation
- Widgets
- Configuration
- Security
- Troubleshooting
- Deploying dashboards
- How Tos
- How to: post data to your dashboard and widgets
- How to: Define a data model and store history data to database
- How to: Prevent a job from overlapping with itself
- How to: Send HTML data to your widgets
- How to: Send mysql data to your widgets
- How to: Setup a Graph
- How to: Store data to and display from database
- How to: Update a Dashboard using a spreadsheet
- How to: update dashboard in Django
- How to: Update font awesome fonts from version 3 to 4
- How to: Use New Relic with Dashing
- How to: precompile assets
- Development