Ich habe Ruby 2.2.4 auf Windows 10, beide x64. Ich hatte ein funktionierendes Shopify Dashing-Juwel und zeigte alles an, bis ich versuchte, eines meiner Widgets aus einer MySQL-Tabelle zu bestücken.Dashing und mySQL mit Ruby unter Windows
Ich habe Shopify Wikis gefolgt Tutorial so meine .rb Datei sieht wie folgt aus:
require 'mysql2'
# :first_in sets how long it takes before the job is first run. In this case, it is run immediately
SCHEDULER.every '1s', :first_in => 0 do |job|
send_event('response_time1', {value: (rand*400).to_i })
send_event('response_time2', {value: (rand*400).to_i })
# MySQL connection
db = Mysql2::Client.new(:host => "127.0.0.1", :username => "root", :password => "root", :port => 3306, :database => "classicmodels")
# MySQL query
sql = "SELECT jobTitle AS title , COUNT(jobTitle) AS count FROM employees GROUP BY jobTitle 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['title'],
:value => row['count']
}
end
# Update the List widget
send_event('sql', { items: acctitems })
end
Es ist ein Schmerz war, aber schließlich habe ich erfolgreich mysql2 gem installiert ist, oder zumindest, wenn ich Liste Edelsteine, I can see it.
Aber jetzt, wenn ich versuche, Dashing zu starten, bekomme ich this error.
Kann mir jemand helfen, damit das funktioniert?