Getting Data From MySQL Using Ruby.

I wanted a fast way to get data from mysql using ruby. after i installed the mysql gem it was really easy. This program gets all rows, but only displays the id,name and zip.

require "mysql"

dbh = Mysql.real_connect("localhost", "root", "password", "scottwork")
res = dbh.query("SELECT name,address,city,state,zip,email FROM contacts")

while row = res.fetch_row do
    id = row[0]
    name = row[1]
    address = row[2]
    city = row[3]
    state = row[4]
    zip = row[5]
    email = row[6]
    puts id+','+name+','+zip