From: Tom Reilly Date: 2011-10-16T05:58:46+09:00 Subject: Re: Ruby and MySQl here is a short program i use to look up stuff on a mysql database using windows 7 ================================================ require 'mysql' host = 'localhost' username = 'root' password = 'tomsfiles' database = 'phnmsg' dbquery = "show columns from encounter" begin wa = Array.new p "--0" conn = Mysql.new(host, username, password, database) rs = conn.query(dbquery) p rs.class rs.each_hash {|r| wa.push(r)} wa.each {|x| p x} wa.each {|x| p x["Field"]} rescue Mysql::Error => e puts "Error! #{e.to_s}" ensure conn.close if conn end ====================================== vikram Hosamane wrote: > Hi, > > Following is the program for database connection > > require 'rubygems' > require 'dbi' > > dbh = DBI.connect('DBI:mysql:ruby', 'root', 'root') > if dbh > puts "database connected successfully" > else > puts "database should not connect" > end > dbh.disconnect > > When I try to run the above code for database connection i got errors > which i have attached. > > please help me to overcome this problem. > > Attachments: > http://www.ruby-forum.com/attachment/6679/d.png > >