Matthew Hagerty <mhagerty@voyager.net> writes:
> but I also want to check the connection
> *before* submitting a query...
This strikes me as utterly pointless. You'll need to be able to recover
from query failure anyway, so what's the value of testing beforehand?
Send the query and see if it works or not.
regards, tom lane