No commit activity in last 3 years
No release in over 3 years
generate bulk insert without ActiveRecord.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
>= 0
>= 0
~> 10.0
~> 3.0
 Project Readme

SugoiBulkInsert

Requirements

  • ruby 2.2.0 later

Installation

Add this line to your application's Gemfile:

gem 'sugoi_bulk_insert'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sugoi_bulk_insert

Usage

mysql> show create table comments;
+----------+--------------------------------------+
| Table    | Create Table                                                                                                                                                                                                                                                                                   |
+----------+--------------------------------------+
| comments | CREATE TABLE `comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `commentable_type` varchar(255) DEFAULT NULL,
  `commentable_id` int(11) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `body` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=480010 DEFAULT CHARSET=utf8 |
+----------+--------------------------------------+
1 row in set (0.00 sec)
b = SugoiBulkInsert.new(table_name: "comments", count: 300) do |x|
  x.column :commentable_type, %w(AAA VVV CCC GGG)
  x.column :commentable_id, 1..300000
  x.column :title, 'aaaa'
  x.column :body, 'aaaa'
end
b.to_sql # => display insert sql
b.fire # => insert! if require "mysql2"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jiikko/sugoi_bulk_insert.