Skip to content

Instantly share code, notes, and snippets.

@metalelf0
Created November 16, 2010 20:15
Show Gist options
  • Save metalelf0/702423 to your computer and use it in GitHub Desktop.
Save metalelf0/702423 to your computer and use it in GitHub Desktop.
MysqlQueryResultsFormatter
module MysqlQueryResultsFormatter
require 'terminal-table/import'
def print_results_of_query query
result = ActiveRecord::Base.connection.execute(query)
return nil if result.nil?
results_table = table do |t|
results = result.all_hashes
t.headings = results.first.keys
results.each do |each_row|
t << each_row.values
end
end
puts results_table
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment