Sha256: 287f9db63163a203e6419f9afae0b5bef04d6ad480d8eb9edfcf221960eead86

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 Bytes

Contents

module Chicago
  module ETL
    module SequelExtensions
      module LoadDataInfile
        # Loads the CSV data columns in filepath into this dataset's table.
        def load_csv_infile(filepath, columns)
          execute_dui(load_csv_infile_sql(filepath, columns))
        end
        
        def load_csv_infile_sql(filepath, columns)
          replacement = opts[:insert_ignore] ? "IGNORE" : "REPLACE"
          "LOAD DATA INFILE '#{filepath}' #{replacement} INTO TABLE `#{opts[:from].first}` CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' (`#{columns.join('`,`')}`);"
        end
      end
    end
  end
end

Sequel::Dataset.send :include, Chicago::ETL::SequelExtensions::LoadDataInfile

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chicago-etl-0.0.9 lib/chicago/etl/sequel/load_data_infile.rb