lib/pg_csv.rb in pg_csv-0.1 vs lib/pg_csv.rb in pg_csv-0.1.1

- old
+ new

@@ -23,10 +23,13 @@ end # do export :to - filename or stream def export(to, opts = {}) @local_options = opts + + raise ":connection should be" unless connection + raise ":sql should be" unless o(:sql) with_temp_file(to, o(:temp_file), o(:temp_dir)) do |_to| export_to(_to) end end @@ -62,11 +65,11 @@ when :file check_to_str(to) File.open(to, 'w', &exporter) when :gzip - check_to_str(to) + check_to_str(to) Zlib::GzipWriter.open(to, &exporter) when :stream exporter[to] @@ -82,11 +85,11 @@ result end def check_to_str(to) - raise "to should be an string" unless to.is_a?(String) + raise "'to' should be an string" unless to.is_a?(String) end def export_to_stream(stream) write_csv(stream) stream.flush @@ -104,19 +107,19 @@ count end def load_data info "#{query}" - conn = connection.raw_connection + raw = connection.raw_connection info "=> query" - q = conn.exec(query) + q = raw.exec(query) info "<= query" info "=> write data" yield(columns_str) if columns_str - while row = conn.get_copy_data() + while row = raw.get_copy_data() yield row end info "<= write data" q.clear \ No newline at end of file