Sha256: 6b0a48d3b0a3bbc6964112b67b806b16299b82b79e5dfa7379e2ba94ecff3097

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 KB

Contents

h1. activerecord-import

activerecord-import is a library for bulk inserting data using ActiveRecord. 

h2. Why activerecord-import?

Because plain-vanilla, out-of-the-box ActiveRecord doesn't provide support for inserting large amounts of data efficiently. With vanilla ActiveRecord you would have to perform individual save operations on each model:

<pre>
10.times do |i|
  Book.create! :name => "book #{i}"
end
</pre> 

This may work fine if all you have is 10 records, but if you have hundreds, thousands, or millions of records it can turn into a nightmare. This is where activerecord-import comes into play. 

h2. An Introductory Example

Here's an example with equivalent behaviour using the @#import@ method:

<pre>
books = []
10.times do |i| 
  books << Book.new(:name => "book #{i}")
end
Book.import books
</pre>

This call to import does whatever is most efficient for the underlying database adapter.  Pretty slick, eh?

h2. Features

Here's a list of some of the high-level features that activerecord-import provides:

* activerecord-import can work with raw columns and arrays of values (fastest)
* activerecord-import works with model objects (faster)
* activerecord-import can perform validations (fast)
* activerecord-import can perform on duplicate key updates (requires mysql)


h1. Upgrading from ar-extensions

activerecord-import replaces the ar-extensions library and is compatible with Rails 3. It provides the exact same API for importing data, but it does not include any additional ar-extensions functionality.

h1. License

This is licensed under the ruby license. 

h1. Author

Zach Dennis (zach.dennis@gmail.com)

h1. Contributors

* Blythe Dunham
* Gabe da Silveira
* Henry Work
* James Herdman
* Marcus Crafter
* Thibaud Guillaume-Gentil
* Mark Van Holstyn 
* Victor Costan

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-import-0.2.5 README.textile
activerecord-import-0.2.4 README.textile
activerecord-import-0.2.3 README.textile
activerecord-import-0.2.2 README.textile
activerecord-import-0.2.1 README.textile
activerecord-import-0.2.0 README.textile