From: Francesco Vollero Date: 2010-04-26T18:13:33+09:00 Subject: Re: connect mysql:show tables Il 26/04/10 04.33, Pen Ttt ha scritto: > require "mysql" > dbh = Mysql.real_connect("localhost", "root", "******", "valuation") > res = dbh.query("show tables") > puts res > res.free > > the output is: > # > > in mysql console: > > mysql> show tables; > +---------------------+ > | Tables_in_valuation | > +---------------------+ > | balance_sheet | > | test | > +---------------------+ > 2 rows in set (0.00 sec) > > how can i get it with ruby? > Is more simple than you think... i just rewrite your code with a little "add": require "mysql" dbh = Mysql.real_connect("localhost", "root", "******", "valuation") res = dbh.query("show tables") - puts res + puts "Tables_in_valutation" + res.each {|x| p x.to_s} res.free Or... require "mysql" dbh = Mysql.real_connect("localhost", "root", "******", "valuation") res = dbh.query("show tables") - puts res + rows = [] + puts "Tables_in_valutation" + res.each {|x| p x.to_s; rows<