Le code :
` ------------- Methode qui checke avant une route si la connection est valide ------
def check_connection( conn )
begin
@conn.exec("SELECT 1")
puts "------ DB CHECK CONNECTION ---- #{@conn.exec("SELECT 1")} ----------------"
rescue PG::Error => err
$stderr.puts "%p while CHECKING TESTING connection: %s" % [ err.class, err.message ]
@conn.reset
puts "--------- PG CONNECTION RESETED -------------"
end
end
Le code : ` ------------- Methode qui checke avant une route si la connection est valide ------ def check_connection( conn ) begin @conn.exec("SELECT 1") puts "------ DB CHECK CONNECTION ---- #{@conn.exec("SELECT 1")} ----------------" rescue PG::Error => err $stderr.puts "%p while CHECKING TESTING connection: %s" % [ err.class, err.message ] @conn.reset puts "--------- PG CONNECTION RESETED -------------" end end
------------ End
check_connection(@conn) `