Class: DataImp::Tds
- Inherits:
-
Object
show all
- Extended by:
- Finders
- Defined in:
- lib/data_imp/tds.rb
Defined Under Namespace
Classes: Table
Instance Method Summary
collapse
Methods included from Finders
extended, find_importer, find_parser, included
Constructor Details
#initialize(options = {}) ⇒ Tds
Returns a new instance of Tds.
6
7
8
|
# File 'lib/data_imp/tds.rb', line 6
def initialize options={}
@options = options
end
|
Instance Method Details
#client ⇒ Object
14
15
16
|
# File 'lib/data_imp/tds.rb', line 14
def client
@client ||= TinyTds::Client.new options
end
|
#import(table) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# 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) ⇒ Object
44
45
46
47
48
|
# 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 ⇒ Object
10
11
12
|
# File 'lib/data_imp/tds.rb', line 10
def options
@options ||= {}
end
|
#show_progress(index) ⇒ Object
50
51
|
# File 'lib/data_imp/tds.rb', line 50
def show_progress index
end
|