Rails Ruby 如何关闭 PostgreSQL 数据库连接

Cger007 · February 27, 2018 · Last by gzhi1992 replied at February 27, 2018 · 1882 hits

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
Cger007 closed this topic. 28 Feb 09:52
Cger007 reopened this topic. 28 Feb 09:53
Cger007 closed this topic. 28 Feb 09:54
You need to Sign in before reply, if you don't have an account, please Sign up first.