GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Trivial async MySQL driver for Ruby EventMachine

Home

Welcome to the asymy wiki!

EventMachine::run {
  c = Asymy::Connection.new(:target => "localhost",
                            :port => 13306,
                            :username => "user",
                            :password => "pass",
                            :database => "mysql")
  c.exec("show databases") do |fields, rows|
      pp fields
      pp rows
  end
}

an example of doing many asynchronous queries: [without using threads]

conns = 0.upto(20).map {|i| Asymy::Connection.new(opts)}
0.upto(10) do |i|
  conns[i].exec("select * from huge_table") {|cols, rows| pp [i, rows.size]}
end
0.upto(10) do |i|
  conns[10+i].exec("select COUNT(*) from tiny_table") {|cols, rows|
       pp [i, rows.size]
   }
end
Last edited by rogerdpack, 3 months ago
Versions: