IT虾米网

ruby连接mysql代码

luoye 2018年06月24日 数据库 1109 0
require 'mysql'       
m = Mysql.new("localhost","name","password","dbname")    
r = m.query("SELECT * FROM people ORDER BY name")    
r.each_hash do |f|    
 print "#{f['name']} - #{f['email']}"    
end 

评论关闭
IT虾米网

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