Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections
От | Adrian Klaver |
---|---|
Тема | Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections |
Дата | |
Msg-id | 3f5dbc35-3578-4036-bbd4-94efdffe1718@aklaver.com обсуждение исходный текст |
Ответ на | Re: Best Practices for Checking PostgreSQL Server Mode with Multiple Connections (YoungUk Song <pidaoh@g.skku.edu>) |
Список | psycopg |
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 adrian.klaver@aklaver.com
В списке psycopg по дате отправления: