Method: ETL::Processor::BulkImportProcessor#initialize

Defined in:
lib/etl/processor/bulk_import_processor.rb

#initialize(control, configuration) ⇒ BulkImportProcessor

Initialize the processor.

Configuration options:

  • :file: The file to load data from

  • :target: The target database

  • :table: The table name

  • :truncate: Set to true to truncate before loading

  • :columns: The columns to load in the order they appear in the bulk data file

  • :field_separator: The field separator. Defaults to a comma

  • :line_separator: The line separator. Defaults to a newline

  • :field_enclosure: The field enclosure charcaters

  • :disable_keys: Set to true to disable keys before, then enable after load (MySql only optimization)

Raises:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/etl/processor/bulk_import_processor.rb', line 44

def initialize(control, configuration)
  super
  @target = configuration[:target]
  path = Pathname.new(configuration[:file])
  @file = path.absolute? ? path : Pathname.new(File.dirname(File.expand_path(control.file))) + path

  @table = configuration[:table]
  @truncate = configuration[:truncate] ||= false
  @columns = configuration[:columns]
  @field_separator = (configuration[:field_separator] || ',')
  @line_separator = (configuration[:line_separator] || "\n")
  @null_string = (configuration[:null_string] || "")
  @field_enclosure = configuration[:field_enclosure]
  @disable_keys = configuration[:disable_keys] || false
  @replace = configuration[:replace] || false
  
  raise ControlError, "Target must be specified" unless @target
  raise ControlError, "Table must be specified" unless @table
end