Problem to fetch data with ruby and mysql

Hi,
    Just yesterday I successfully installed ruby in my pc, means I am
new in this technology.
    Today I am trying to fetch the data in my ruby application and
successfully done this. Now I want to speed up the performance of the
fetching data by making use of prepare and execute method.In case of
select query also I am using this like

   require 'mysql'
   mysql = Mysql.init()
   mysql.connect('localhost','root','','ruby')
   selection = mysql.prepare("select * from test where id=?")
   result = selection.execute(2)
   while row = result.fetch_hash do
     puts "The name is: #{row['name']}"
   end
   mysql.close();

So when I run this small part of the application I am getting the
following error:
       in `<top (required)>': undefined method `fetch_hash' for
#<Mysql::Stmt:0xf9d128> (NoMethodError)
  from -e:1:in `load'
  from -e:1:in `<main>'

But if we write code like:
   require 'mysql'
   mysql = Mysql.init()
   mysql.connect('localhost','root','','ruby')
   result = mysql.query("select * from test where id=2")
   while row = result.fetch_hash do
     puts "The name is: #{row['name']}"
   end
   mysql.close();

then my application is running without error.

Now my question is, if we try to fetch the data by making use of prepare
and execute method then what will be the available methods for showing
the records?

···

--
Posted via http://www.ruby-forum.com/.

I see more relevance in 'mysql2'

This are just the 2 top Google results for "gem list mysql mysql2"
Other results there will be relevant too.

  GitHub - brianmario/mysql2: A modern, simple and very fast Mysql library for Ruby - binding to libmysql

maybe some methods that you found in documentation where not even
implemented
myslq but only in newer mysql2.

try the command:

$ gem list -r mysql

(this will report all "remote" gems that start with mysql....)

HTH,

Peter

···

On Thu, Feb 2, 2012 at 2:16 PM, Srimanta Chakraborty <srimanta12@gmail.com>wrote:

Hi,
   Just yesterday I successfully installed ruby in my pc, means I am
new in this technology.
   Today I am trying to fetch the data in my ruby application and
successfully done this. Now I want to speed up the performance of the
fetching data by making use of prepare and execute method.In case of
select query also I am using this like

  require 'mysql'