Class: LoadDataInfile2::Client

Inherits:
Mysql2::Client
  • Object
show all
Defined in:
lib/load_data_infile2/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/load_data_infile2/client.rb', line 8

def initialize(config, options = {})
  c = if options[:local_infile] && !config.has_key?(:local_infile) && !config.has_key?('local_infile')
        config.merge(local_infile: true)
      else
        config
      end
  super(c)

  @load_data_infile_options = LoadDataInfile2.default_import_options.merge(options)
  @load_data_infile_options[:charset] = query_options[:charset] unless options.has_key?(:charset)
end

Instance Attribute Details

#load_data_infile_optionsObject (readonly)

Returns the value of attribute load_data_infile_options.



6
7
8
# File 'lib/load_data_infile2/client.rb', line 6

def load_data_infile_options
  @load_data_infile_options
end

Instance Method Details

#import(file, options = {}) ⇒ Object



20
21
22
# File 'lib/load_data_infile2/client.rb', line 20

def import(file, options = {})
  query(build_sql(file, options))
end

#quoted_table_name_for(table) ⇒ Object



24
25
26
# File 'lib/load_data_infile2/client.rb', line 24

def quoted_table_name_for(table)
  [query_options[:database], table].compact.map!{|w| "`#{w}`"}.join('.')
end