module Sequel::LoadDataInfile
Public Instance Methods
load_csv_infile(path, columns, options={})
click to toggle source
Loads the CSV data columns in path into this dataset’s table.
See load_infile
for more options.
# File lib/sequel/load_data_infile.rb, line 150 def load_csv_infile(path, columns, options={}) execute_dui(load_csv_infile_sql(path, columns, options)) end
load_csv_infile_sql(path, columns, options={})
click to toggle source
# File lib/sequel/load_data_infile.rb, line 154 def load_csv_infile_sql(path, columns, options={}) load_infile_sql(path, columns, options.merge(:format => :csv)) end
load_infile(path, columns, options={})
click to toggle source
Load data in file specified at path.
Columns is a list of columns to load - column names starting with an @ symbol will be treated as variables.
By default, this will generate a REPLACE INTO TABLE statement.
Options: :ignore - the number of lines to ignore in the source file :update - nil, :ignore or :replace :set - a hash specifying autopopulation of columns :character_set - the character set of the file, UTF8 default :format - either nil or :csv
# File lib/sequel/load_data_infile.rb, line 131 def load_infile(path, columns, options={}) execute_dui(load_infile_sql(path, columns, options)) end
load_infile_sql(path, columns, options={})
click to toggle source
Returns the SQL for a LOAD DATA INFILE statement.
# File lib/sequel/load_data_infile.rb, line 136 def load_infile_sql(path, columns, options={}) replacement = opts[:insert_ignore] ? :ignore : :replace options = {:update => replacement}.merge(options) LoadDataInfileExpression.new(path, opts[:from].first, columns, options). to_sql(db) end