Skip to content

jylamont/bulk_insert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BulkInsert

Quick and dirty mass-insert with ActiveRecord and PostgreSQL. This gem assumes that all data being inserted has already been validated, and that table and column names have been checked for SQL injection vulnerabilities.

Installation

Add this line to your application's Gemfile:

gem 'bulk_insert'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bulk_insert

Usage

BulkInsert::Handler.new(table_name, [*column_names]).insert([*rows])

For example, to insert 10 comments into your database you can use the following...

BulkInsert::Handler.new("comments", ["id", "author_id", "text", "created_at"]).insert([
  {"id" => 1, "author_id" => 1, "text" => "Hello world!", "created_at" => "now"},
  ...
])

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages