ruby 判断是否连接到 postgreSQL 数据库,如下关闭连接怎么写
temp = "host=" + conf['host'].to_s + " port=" + 5432.to_s + " dbname=" + conf['database'].to_s + " user=" + conf['username'].to_s + " password=" + conf['password'].to_s
cardinfos_conf = temp.to_s
# 连接到 MySQL服务器
$CAN_CONNECTION = false
begin
@conn = PGconn.connect(cardinfos_conf)
if @conn.status == PGconn::CONNECTION_OK
$CAN_CONNECTION = true
end
rescue PGError
关闭连接???
end