Sha256: 9e1ac4255325f80b35c3a0aa57a95ac11d76ba3b69ff68bc9f6bd14795f8609c
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module ETL #:nodoc: module Processor #:nodoc: # A processor which will truncate a table. Use as a pre-processor for cleaning out a table # prior to loading class TruncateProcessor < ETL::Processor::Processor # Defines the table to truncate attr_reader :table # Defines the database connection to use attr_reader :target # Initialize the processor # # Options: # * <tt>:target</tt>: The target connection # * <tt>:table</tt>: The table name # * <tt>:options</tt>: Optional truncate options def initialize(control, configuration) super #@file = File.join(File.dirname(control.file), configuration[:file]) @target = configuration[:target] || {} @table = configuration[:table] @options = configuration[:options] end def process conn = ETL::Engine.connection(target) @options ||= 'RESTART IDENTITY' if conn.class.name =~ /postgres/i conn.truncate(table_name, @options) end private def table_name ETL::Engine.table(table, ETL::Engine.connection(target)) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activewarehouse-etl-1.0.0 | lib/etl/processor/truncate_processor.rb |
activewarehouse-etl-1.0.0.rc1 | lib/etl/processor/truncate_processor.rb |