Skip to content

Instantly share code, notes, and snippets.

Created July 24, 2015 06:49
Show Gist options
  • Save anonymous/7ab55a033c659586641d to your computer and use it in GitHub Desktop.
Save anonymous/7ab55a033c659586641d to your computer and use it in GitHub Desktop.
client = Mysql2::Client.new(:default_file => 'my-client.cnf', :default_group => 'client'")
results = client.query("SHOW DATABASES")
results.each do |row|
puts "#{row['Database']}"
end
---
Output
information_schema
monitoring
mysql
notification
---
What I want to do is then loop through the output and run this query, but exclude mysql and information_schema
mysql> SELECT COUNT(DISTINCT `table_name`) FROM `information_schema`.`columns` WHERE `table_schema` = 'monitoring';
+------------------------------+
| COUNT(DISTINCT `table_name`) |
+------------------------------+
| 4 |
+------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment