Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def client
- Mysql2::EM::Client.new(
- :host => "localhost",
- :username => DbConfig['user'],
- :password => DbConfig['password'],
- :database => DbConfig['database'])
- end
- def query(query, &block)
- new_client = client
- result = new_client.query(query)
- result.callback do |results|
- block.call(results)
- new_client.close
- end
- end
- EM::run do
- query("SELECT * FROM USERS") do |users|
- # ...
- end
- end
Add Comment
Please, Sign In to add comment