class DataImp::Tds
Public Class Methods
new(options={})
click to toggle source
# File lib/data_imp/tds.rb, line 6 def initialize options={} @options = options end
Public Instance Methods
client()
click to toggle source
# File lib/data_imp/tds.rb, line 14 def client @client ||= TinyTds::Client.new options end
import(table)
click to toggle source
# File lib/data_imp/tds.rb, line 18 def import table table.strip! return if table =~ /^#/ parts = table.split('.') table = parts.pop schema = parts.shift importer = find_importer(table) tbl = Table.new(client, table, schema: schema) puts "Importing #{table} with #{importer}" importer.before_all_imports tbl.each do |hash, index| porter = importer.new(hash,index) begin porter.before_import porter.import porter.after_import show_progress index rescue StandardError => e warn "#{table}:#{index}:#{e.class.name}" porter.on_error e end end importer.after_all_imports puts end
import_list(list, *args, &block)
click to toggle source
# File lib/data_imp/tds.rb, line 44 def import_list list, *args, &block list.each_line do |table| import table, *args, &block end end
options()
click to toggle source
# File lib/data_imp/tds.rb, line 10 def options @options ||= {} end
show_progress(index)
click to toggle source
# File lib/data_imp/tds.rb, line 50 def show_progress index end