Method: PG::Connection#status

Defined in:
ext/pg_connection.c

#statusObject

Returns the status of the connection, which is one:

PG::Constants::CONNECTION_OK
PG::Constants::CONNECTION_BAD

… and other constants of kind PG::Constants::CONNECTION_*

This method returns the status of the last command from memory. It doesn’t do any socket access hence is not suitable to test the connectivity. See check_socket for a way to verify the socket state.

Example:

PG.constants.grep(/CONNECTION_/).find{|c| PG.const_get(c) == conn.status} # => :CONNECTION_OK


794
795
796
797
798
# File 'ext/pg_connection.c', line 794

static VALUE
pgconn_status(VALUE self)
{
  return INT2NUM(PQstatus(pg_get_pgconn(self)));
}