Sha256: 5851189c368dc0aa7a3aba3ae14f0892eb87964018bcd603ce4f5bde9a4a6d9a

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

require_relative "../helpers/errors"
require "pry"
module CsvImportAnalyzer
  module PgQueryHelper

    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?
        pg_import_statement = "COPY #{args[:tablename]} FROM '#{args[:filename]}' HEADER DELIMITER '#{args[:delimiter]}' CSV NULL AS 'NULL';"
      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/pg_query_helper.rb
csv-import-analyzer-0.0.2 lib/csv-import-analyzer/query_builder/pg_query_helper.rb
csv-import-analyzer-0.0.1 lib/csv-import-analyzer/query_builder/pg_query_helper.rb