No commit activity in last 3 years
No release in over 3 years
This gem allows you to insert multiple rows as once, dramatically increasing performance.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
>= 0

Runtime

 Project Readme

Bulk Insert Active Record (for ActiveRecord 3 or higher)

This gem extends Active Record and allows you to insert multiple records in one SQL statement, dramatically increasing performance.

Current status

This gem is currently actively in development, but because it's already useful, I've decided to publish it in its premature state. Right now it has been manually tested with MySQL, SQL Server and Oracle via JDBC.

Usage

Installation is done by adding the gem your Gemfile and running Bundler. After loading Active Record an extra class method is available for your models.

Examples

Suppose you want to insert multiple Post records in the database. This can be done in different ways:

# suppose it has 3 columns (`id`, `author` and `text`)
class Post < ActiveRecord::Base
end

# create an array of arrays
posts = [
	# author, # text
	['John Doe', 'An article about me'],
	['John Smith', 'Something interesting']
]

# call class method bulk_insert with two arguments (the posts and the column names)
Post.bulk_insert(posts, ['author', 'name])

Copyright

© 2016 Walter Horstman, IT on Rails