Skip to content

Instantly share code, notes, and snippets.

@florianeck
Created March 9, 2016 11:29
Show Gist options
  • Save florianeck/789e448f77a4eebbb4fc to your computer and use it in GitHub Desktop.
Save florianeck/789e448f77a4eebbb4fc to your computer and use it in GitHub Desktop.
quickrun sql query and output CSV for copy/paste
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