Kirisame: とりあえず結果の取得まで

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/kirisame/ext/?root=svn

require 'kirisame'

client = Kirisame::Client.tcp('127.0.0.1', 3306, 'root', nil, 'mysql')
qs = client.query('show tables', 'show databases')

qs.run_all

qs.each_with_index do |q, i|
  puts "\n-----\nquery:#{i}"

  while (row = q.row_buffer)
    p row
  end
end

puts "\n====="

qs = client.query('select sleep(3)', 'select sleep(60)')

begin
  while q = qs.run(5000)
    p q.row_buffer
  end
rescue Kirisame::Timeout => e
  puts e.message
end

qs.close


        • -

query:0
["columns_priv"]
["db"]
["func"]
["help_category"]
["help_keyword"]
["help_relation"]
["help_topic"]
["host"]
["proc"]
["procs_priv"]
["tables_priv"]
["time_zone"]
["time_zone_leap_second"]
["time_zone_name"]
["time_zone_transition"]
["time_zone_transition_type"]
["user"]
["user_info"]

        • -

query:1
["information_schema"]
["hoge"]
["mysql"]

["0"]
drizzle_con_wait:timeout reached

いくつかメモ。

  • Columnクラスを作る
  • xxx_nonblockメソッドが必要かも
    • Timeout例外を投げないだけ
  • 単体クエリを別コネクションで発行できるメソッドは必要かなぁ…