- require 'mysql'
- m = Mysql.new("localhost","ruby","secret","maillist")
- r = m.query("SELECT * FROM people ORDER BY name")
- r.each_hash do |f|
- print "#{f['name']} - #{f['email']}"
- end
- #该片段来自于http://www.codesnippet.cn/detail/090920135746.html
来源: http://www.codesnippet.cn/detail/090920135746.html