Sha256: b214ab1a8cf20ea52b118779783af8ffdc867d384382484c2f0e095a9f78c265
Contents?: true
Size: 641 Bytes
Versions: 1
Compression:
Stored size: 641 Bytes
Contents
if RUBY_VERSION >= '1.9' require 'csv' else require 'fastercsv' end module Mysql2xxxx class CSV include ExtraOutputs attr_reader :properties def initialize(options = {}) @properties = Properties.new options end def to_file(f) @client = ::Mysql2::Client.new properties.database_config keys = nil @client.query(properties.execute).each do |hsh| unless keys keys = hsh.keys f.write keys.to_csv end f.write keys.inject([]) { |memo, k| memo.push hsh[k] }.to_csv end nil ensure @client.try :close end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mysql2xxxx-0.0.3 | lib/mysql2xxxx/csv.rb |