Guest User

Untitled

a guest
Nov 26th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. require "pg"
  2.  
  3. class Uploader
  4. INSERT_AMOUNT = 2000
  5.  
  6. def insert
  7. INSERT_AMOUNT.times do
  8. connection.exec("insert into common_dictionary (type, name, end_date, status, par_id) values ('shop', 'my shop_#{Random.rand}', current_timestamp, true, 1);");
  9. connection.exec("insert into common_dictionary (type, name, end_date, status, par_id) values ('card_type', 'my card_type_#{Random.rand}', current_timestamp, true, 1);");
  10. connection.exec("insert into common_dictionary (type, name, end_date, status, par_id) values ('event', 'my event_type_#{Random.rand}', current_timestamp, true, 1);");
  11. connection.exec("insert into common_dictionary (type, name, end_date, status, par_id) values ('event', 'my event_type_#{Random.rand}', current_timestamp, false, 1);");
  12. connection.exec("insert into common_dictionary (type, name, end_date, status, par_id) values ('adress', 'my adress_#{Random.rand}', current_timestamp, true, 1);");
  13. end
  14. end
  15.  
  16. private
  17.  
  18. def connection
  19. @connection ||= PG.connect dbname: "SMDB", user: "moskieva", password: ""
  20. end
  21. end
  22.  
  23. uploader = Uploader.new
  24. uploader.insert
Add Comment
Please, Sign In to add comment