paolodona / import_with_load_data_in_file
- Source
- Commits
- Network (2)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
b7b3b08
Paolo Dona (author)
Wed Oct 15 13:54:26 -0700 2008
commit b7b3b088160779e72f180f9f2592f5dc17c113fc
tree d3afd9148bd6038d4cf00e19c4f11e8fa8a62389
parent 1d7a9779d962ab9133485039143bd6110eb778b9
tree d3afd9148bd6038d4cf00e19c4f11e8fa8a62389
parent 1d7a9779d962ab9133485039143bd6110eb778b9
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
MIT-LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
test/ | ||
| |
uninstall.rb |
README
ImportWithLoadDataInFile ======================== This plugin allows you to bulk import records into a table using mysql's 'LOAD DATA INFILE' feature. It is very similar to ar-extensions import feature, but it seems to be about 30% faster. all it does is: - take a list of columns and a 2D Array with the column values - create a tempfile and put a csv representation of the data in it - call mysql's LOAD DATA INFILE against the temp file Example ======= # Table name: users # # id :integer(11) not null, primary key # name :string(20) # surname :string(32) # class User < ActiveRecord::Base # you need to include this module include ImportWithLoadDataInFile end cols = [:name, :surname] vals = [["paolo", "dona"], ["james", "dean"]] User.import_with_load_data_infile(cols, vals) # this generates a LOAD DATA LOCAL INFILE statement # if your db is on the same machine of the app server, you can switch off the LOCAL flag User.import_with_load_data_infile(cols, vals, :local => false) # this generates LOAD DATA INFILE

