(db_alias)
Finds the replication delay for given database by running a SQL query on standby database.
        See https://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com

    If standby process (wal_receiver) is not running on standby -1 is returned
Finds the replication delay for given database by running a SQL query on standby database.
        See https://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com
Finds the replication delay for given database by running a SQL query on standby database . See https : // www . postgresql . org / message - id / CADKbJJWz9M0swPT3oqe8f9 + tfD4 - F54uE6Xtkh4nERpVsQnjnw@mail . gmail . com
def get_replication_delay_for_standby(db_alias):
    """
    Finds the replication delay for given database by running a SQL query on standby database.
        See https://www.postgresql.org/message-id/CADKbJJWz9M0swPT3oqe8f9+tfD4-F54uE6Xtkh4nERpVsQnjnw@mail.gmail.com

    If standby process (wal_receiver) is not running on standby -1 is returned
    """
    # used to indicate that the wal_receiver process on standby is not running
    try:
        sql = REPLICATION_SQL_10 if get_db_version(db_alias) >= PG_V10 else REPLICATION_SQL_9_6
        with connections[db_alias].cursor() as cursor:
            cursor.execute(sql)
            [(delay, )] = cursor.fetchall()
            return delay
    except OperationalError:
        return -1
def get_replication_delay_for_standby ( db_alias ) : # used to indicate that the wal_receiver process on standby is not running try : sql = REPLICATION_SQL_10 if get_db_version ( db_alias ) >= PG_V10 else REPLICATION_SQL_9_6 with connections [ db_alias ] . cursor ( ) as cursor : cursor . execute ( sql ) [ ( delay , ) ] = cursor . fetchall ( ) return delay except OperationalError : return - 1