Class: Mysqlexport::Csv
Instance Attribute Summary
Attributes inherited from Writer
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Csv
constructor
A new instance of Csv.
- #to_file(file) ⇒ Object
Methods inherited from Writer
#filter_path, #to_path, #to_s, #to_stdout
Constructor Details
#initialize(options = {}) ⇒ Csv
Returns a new instance of Csv.
8 9 10 |
# File 'lib/mysqlexport/writer/csv.rb', line 8 def initialize( = {}) super(**) end |
Instance Method Details
#to_file(file) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/mysqlexport/writer/csv.rb', line 12 def to_file(file) result = client.query(config.execute, stream: true, cache_rows: false, as: :array) csv_o = file.write result.fields.to_csv(**csv_o) if config.csv_heading result.each do |row| file.write row.to_csv(**csv_o) end end |