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
# File 'lib/load_data_infile2/client.rb', line 8

def initialize(config, options = {})
  if options[:local_infile]
    config = config.merge(local_infile: true)
  end
  super(config)

  @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



18
19
20
# File 'lib/load_data_infile2/client.rb', line 18

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

#quoted_table_name_for(table) ⇒ Object



22
23
24
# File 'lib/load_data_infile2/client.rb', line 22

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