Home

rdp edited this page Sep 14, 2010 · 6 revisions
Clone this wiki locally

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