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

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/etl/processor/bulk_import_processor.rb', line 37

def initialize(control, configuration)
  super
  @file = File.join(File.dirname(control.file), configuration[:file])
  @target = configuration[:target]
  @table = configuration[:table]
  @truncate = configuration[:truncate] ||= false
  @columns = configuration[:columns]
  @field_separator = (configuration[:field_separator] || ',')
  @line_separator = (configuration[:line_separator] || "\n")
  @field_enclosure = configuration[:field_enclosure]
  
  raise ControlError, "Target must be specified" unless @target
  raise ControlError, "Table must be specified" unless @table
end