Module: Sequel::LoadDataInfile
- Defined in:
- lib/sequel/load_data_infile.rb
Instance Method Summary collapse
-
#load_csv_infile(path, columns, options = {}) ⇒ Object
Loads the CSV data columns in path into this dataset’s table.
- #load_csv_infile_sql(path, columns, options = {}) ⇒ Object
-
#load_infile(path, columns, options = {}) ⇒ Object
Load data in file specified at path.
-
#load_infile_sql(path, columns, options = {}) ⇒ Object
Returns the SQL for a LOAD DATA INFILE statement.
Instance Method Details
#load_csv_infile(path, columns, options = {}) ⇒ Object
Loads the CSV data columns in path into this dataset’s table.
See load_infile for more options.
150 151 152 |
# File 'lib/sequel/load_data_infile.rb', line 150 def load_csv_infile(path, columns, ={}) execute_dui(load_csv_infile_sql(path, columns, )) end |
#load_csv_infile_sql(path, columns, options = {}) ⇒ Object
154 155 156 |
# File 'lib/sequel/load_data_infile.rb', line 154 def load_csv_infile_sql(path, columns, ={}) load_infile_sql(path, columns, .merge(:format => :csv)) end |
#load_infile(path, columns, options = {}) ⇒ Object
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
131 132 133 |
# File 'lib/sequel/load_data_infile.rb', line 131 def load_infile(path, columns, ={}) execute_dui(load_infile_sql(path, columns, )) end |
#load_infile_sql(path, columns, options = {}) ⇒ Object
Returns the SQL for a LOAD DATA INFILE statement.
136 137 138 139 140 141 142 143 144 |
# File 'lib/sequel/load_data_infile.rb', line 136 def load_infile_sql(path, columns, ={}) replacement = opts[:insert_ignore] ? :ignore : :replace = {:update => replacement}.merge() LoadDataInfileExpression.new(path, opts[:from].first, columns, ). to_sql(db) end |