连接方法:
1.需要的gem:rubygems-update-1.3.7.gem mysql-2.7.3-mswin32.gem
2.这两者安装完之后,运行,发现报错,原来是缺少了libmysql.dll
3.拷贝libmysql.dll文件到c:\windows\system32下面
4.代码:
def connect_mysql(host,username,pw,database,port,sql) dbh=Mysql.real_connect(host,username,pw,database,port) begin #yield dbh.query(sql) dbh.query(sql) ensure dbh.close end end