Sha256: 57b12d62cd2b08c665659c08b3feed1437bedf1a32139052773e26a0f8dff53d
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
# BulkseedMysql ## Installation ```ruby gem 'bulkseed_mysql' ``` Or ```bash $ gem install bulkseed_mysql ``` ## Usage Use REPLACE Statement. [see](https://dev.mysql.com/doc/refman/5.6/en/replace.html)<br> If call without primary key, mysql will do DELETE and INSERT<br> Be Carefull!! ```ruby require "bulkseed_mysql" now = Time.now.to_s.split(" ").take(2).join(" ") # => "2021-07-09 22:14:59" seed = BulkseedMysql.new seed.prepare "users" do |s| s.columns = [:id, :name, :sex, :created_at, :updated_at] s.data = [ [1, "hoge", 23, :male, now, now], [2, "fuga", 25, :female, now, now], [3, "piyo", 18, :other, now, now], ] end seed.prepare do |s| # you can also specify here s.table = "admins" # you can also set Array of Hash to data # keys are to be columns s.data = [ { id: 1, name: "foo", email: "admin1@sample.com", created_at: now, updated_at: now, }, { id: 2, name: "bar", email: "admin2@sample.com", created_at: now, updated_at: now, }, ] end # insert all prepared tables seed.call ``` ```ruby require "bulkseed_mysql" # You can call without prepare seed = BulkseedMysql.call "users" do |s| s.data = [ ... ] end ```
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
bulkseed_mysql-0.1.3 | README.md |
bulkseed_mysql-0.1.2 | README.md |
bulkseed_mysql-0.1.1 | README.md |
bulkseed_mysql-0.1.0 | README.md |