IT虾米网

Ruby 连接到 MySQL 并执行SQL查询

developer 2018年06月24日 数据库 1244 0
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 

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!