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

Cger007 · 2018年02月27日 · 最后由 gzhi1992 回复于 2018年02月27日 · 1877 次阅读

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 关闭了讨论。 02月28日 09:52
Cger007 重新开启了讨论。 02月28日 09:53
Cger007 关闭了讨论。 02月28日 09:54
需要 登录 后方可回复, 如果你还没有账号请 注册新账号