Sha256: a6793dd389fa54dc25fcae61d9371e23ad4bedc7dfa5c5e9d41a9000fa3dc02f
Contents?: true
Size: 422 Bytes
Versions: 4
Compression:
Stored size: 422 Bytes
Contents
# frozen_string_literal: true require 'sql_csv/version' require 'active_record' require 'csv' # Create a CSV export from an SQL query. module SqlCsv class Error < StandardError; end def self.export(query) ActiveRecord::Base.establish_connection rows = ActiveRecord::Base.connection.execute(query) csv = CSV.new($stdout) csv << rows.fields rows.each { |row| csv << row } csv.close end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
sql_csv-0.2.1 | lib/sql_csv.rb |
sql_csv-0.2.0 | lib/sql_csv.rb |
sql_csv-0.1.1 | lib/sql_csv.rb |
sql_csv-0.1.0 | lib/sql_csv.rb |