Created
March 9, 2016 11:29
-
-
Save florianeck/789e448f77a4eebbb4fc to your computer and use it in GitHub Desktop.
quickrun sql query and output CSV for copy/paste
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q = '... query here' | |
r = ActiveRecord::Base.connection.execute(q) | |
csv_out = [] | |
csv_out << r.first.keys.join(";") | |
r.each {|x| csv_out << x.values.join(";") } | |
puts csv_out.join("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment