How to use MySQL server from Ruby?

If I have program like following:

require 'rubygems'
require 'mysql'
# Connect to a MySQL database 'test' on the local machine
# using username of 'root' with no password.
db = Mysql.connect('localhost', 'root', '', 'test')
# Perform an arbitrary SQL query
db.query("INSERT INTO people (name, age) VALUES('Chris', 25)")
# Perform a query that returns data
begin
query = db.query('SELECT * FROM people')
puts "There were #{query.num_rows} rows returned"
query.each_hash do |h|
puts h.inspect
end
rescue
puts db.errno
puts db.error
end
# Close the connection cleanly
db.close

How to run this program in Ruby?

Thank you.

···

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

Is this a trick question?

ruby my_prog.rb

···

On Mon, Mar 10, 2014 at 8:09 AM, Jaimin Pandya <lists@ruby-forum.com> wrote:

If I have program like following:

How to run this program in Ruby?