public inbox for [email protected]
help / color / mirror / Atom feedFrom: Adrian Klaver <[email protected]>
To: YoungUk Song <[email protected]>
To: [email protected]
Subject: Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections
Date: Mon, 9 Dec 2024 08:53:21 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAK9ZnjPFsPTd20HHjX8NhpiS9zTJTAde1p30BKx85BqSiM-MgQ@mail.gmail.com>
References: <CAK9ZnjNECXcXshq6OVzx8ryf0i7KNrp9TErhNkL0ga0c=K-GFA@mail.gmail.com>
<[email protected]>
<CAK9ZnjPvnXgZa28gpXWw0A2wkUBJnmm5dtk3sYJKkm9UgnND0Q@mail.gmail.com>
<CAK9ZnjPFsPTd20HHjX8NhpiS9zTJTAde1p30BKx85BqSiM-MgQ@mail.gmail.com>
On 12/9/24 06:04, YoungUk Song wrote:
> Thank you for your response!
>
> I apologize for the confusion in my earlier message.
>
> I need to check whether more than 500 different database servers (not
> just one) are operating in read-only or read-write mode using Psycopg.
>
> Are there any best practices for efficiently handling this task across
> such a large number of servers?
It is a matter of looping over a set of connection settings and
recording the results. To me that points at a Postgres table with the
connections settings and another table that tracks the results of the
connection attempts.
Then it is a matter of writing code that uses psycopg to make
connections using the connection data on whatever schedule you want to
follow. The results of the connection are then written out to the status
table. Where results can be 1) Successful connection and server mode. 2)
Unsuccessful connection and connection error.
>
> Can this be achieved using Psycopg's error-handling features, as
> described here: https://www.psycopg.org/psycopg3/docs/api/errors.html
> <https://www.psycopg.org/psycopg3/docs/api/errors.html;?
Yes use try/except for the connection attempts and capture the error if
there is one.
>
>
> Thanks!
>
--
Adrian Klaver
[email protected]
view thread (5+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox