Sha256: ef1766f8a4f4bac50fd4daf62f6bf5c27c231010b2c2b27f0eb5877c80ff95c6
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module ETL module Processor class BulkImportProcessor < ETL::Processor::Processor attr_reader :file, :target def initialize(control, configuration) super @file = File.join(File.dirname(control.file), configuration[:file]) @target = configuration[:target] connect end def process conn = ActiveRecord::Base.connection conn.transaction do # Since LOCAL is used this must be allowed by both the client and server conn.execute("LOAD DATA LOCAL INFILE '#{file}' INTO TABLE #{target[:table]}") end end private def log unless @log @log = Logger.new(STDOUT) @log.level = Logger::DEBUG end @log end # Connect to the database def connect ActiveRecord::Base.establish_connection( :adapter => (target[:adapter] || :mysql), :username => (target[:username] || 'root'), :host => (target[:host] || 'localhost'), :password => target[:password], :database => target[:database] ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activewarehouse-etl-0.1.0 | lib/etl/processor/bulk_import_processor.rb |