module Examples class Db < Cerise::RequestHandler def handle(request, response) application.with_db_connection("db/Mysql") { |dbh| sth = dbh.prepare('select `id`, `created`, `xml` from `log` order by id desc limit 50') sth.execute data = [] while row = sth.fetch do data.push({ :id => row["id"], :created => row["created"], :xml => row["xml"] }) end { :log => data } } end end end