class Rdb2spreadsheet::DataAdapter

Attributes

rdb_client[R]
spreadsheet_client[R]

Public Class Methods

new(db_configs, spreadsheet_configs) click to toggle source
# File lib/rdb2spreadsheet/data_adapter.rb, line 7
def initialize(db_configs, spreadsheet_configs)
  @rdb_client = RdbClient.new(db_configs)
  @spreadsheet_client = SpreadsheetClient.new(spreadsheet_configs)
end

Public Instance Methods

import_all(book_key, sqls) click to toggle source
# File lib/rdb2spreadsheet/data_adapter.rb, line 12
def import_all(book_key, sqls)
  @spreadsheet_client.open_book_by_key(book_key)
  sqls.each do |worksheet, sql|
    puts worksheet + ' updating'
    headers, records = @rdb_client.select(sql)
    next if headers.nil? || records.nil?
    @spreadsheet_client.update_worksheet(worksheet, headers, records)
    puts worksheet + ' updated'
  end
end