Sha256: b0e51638ed0e3bd51bf40c50ccf5234060a4b6d8fd3e58acadb73e1fa74bc4e3

Contents?: true

Size: 1006 Bytes

Versions: 3

Compression:

Stored size: 1006 Bytes

Contents

require_relative "../helpers/errors"
require 'pry'
module CsvImportAnalyzer
  module MysqlQueryHelper
  
    def form_query_for_datatype(args)
      unless args[:datatype].nil? || args[:header].nil?
        if args[:datatype] == :string
          return args[:header].to_s + " varchar(255)"
        else
          return args[:header].to_s + " " + args[:datatype].to_s
        end
      else
        MissingRequiredArguments.new("Required arguments missing for form_query_for_datatype")
      end
    end

    def import_csv(args)
      unless args[:tablename].nil? || args[:filename].nil? || args[:delimiter].nil?
        import_statement = "LOAD DATA INFILE #{args[:filename]} INTO TABLE #{args[:tablename]} "+
              "FIELDS TERMINATED BY '#{args[:delimiter]}' "+
              "ENCLOSED BY '\"' "+
              "LINES TERMINATED BY '\\n' "+
              "IGNORE 1 LINES;"
      else
        MissingRequiredArguments.new("Required arguments missing for import_csv")
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv-import-analyzer-0.0.3 lib/csv-import-analyzer/query_builder/mysql_query_helper.rb
csv-import-analyzer-0.0.2 lib/csv-import-analyzer/query_builder/mysql_query_helper.rb
csv-import-analyzer-0.0.1 lib/csv-import-analyzer/query_builder/mysql_query_helper.rb