Guest User

Untitled

a guest
Aug 13th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. def client
  2. Mysql2::EM::Client.new(
  3. :host => "localhost",
  4. :username => DbConfig['user'],
  5. :password => DbConfig['password'],
  6. :database => DbConfig['database'])
  7. end
  8.  
  9. def query(query, &block)
  10. new_client = client
  11. result = new_client.query(query)
  12. result.callback do |results|
  13. block.call(results)
  14. new_client.close
  15. end
  16. end
  17.  
  18. EM::run do
  19. query("SELECT * FROM USERS") do |users|
  20. # ...
  21. end
  22. end
Add Comment
Please, Sign In to add comment