From: | Manlio Perillo <manlio_perillo(at)libero(dot)it> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Does PG have a database |
Date: | 2006-05-22 17:59:28 |
Message-ID: | 4471FC00.8010100@libero.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Mark Fenbers ha scritto:
> I have working PostgreSQL databases on 3 of my ~30 Linux boxes. I want
> my software to be able to determine which of my 30 boxes have functional
> databases on them. Since Pg is part of the baseline distro, merely
> checking for the existence of an executable doesn't solve my problem.
>
> I tried looping through my list of hosts and running the command:
> psql -h $host --list
> but this fails on a box with a database with the same error code as on a
> box that doesn't have a database, if my PGUSER isn't set and my login ID
> is not the username of the database. The PGUSER setting might differ
> for each host, so specifying this in the software is not practical.
>
> Bottom line: What trick can I use to determine whether a box has a
> living, breathing Pg database if I don't know the DB owner?
> Mark
>
Just write a custom client that connects to the given host, on some
standard ports.
If the connection is accepted, there is a possibility that on the other
side there is a PostgreSQL server.
To make sure send a StartupMessage
http://www.postgresql.org/docs/8.1/static/protocol-message-formats.html
You can reuse some code of a library I have written: pglib.
http://developer.berlios.de/projects/pglib/
It is released under the MIT license, and it is written in Python and
Twisted (a framework for writing asynchronous applications).
By the way: pglib aims to be a complete replacement for libpq.
Regards Manlio Perillo
From | Date | Subject | |
---|---|---|---|
Next Message | mark.dingee | 2006-05-22 18:58:11 | Question on UNION |
Previous Message | Markus Schaber | 2006-05-22 17:52:49 | Re: Does PG have a database |