pyPgSQL DatabaseError details
Bill.Allie at mug.org
Bill.Allie at mug.org
Sun Dec 29 15:10:13 EST 2002
Reid Lai wrote:
> Hi There,
>
> I am newbie using Python and write a program which connects with my
> PostgreSQL 7.2.x database. In this program, I use try ... except
> PySQL.DatabaseError ... statement to display error in shell level. It
> works fine. But now I am thinking to enhance error message and
> encountered a problem.
>
> How can I extract information from DatabaseError exception to determine
> if database connection problem is due to availability of database
> service or incorrect user id and password? Thanks for any help.
You can use something like this:
from pyPgSQL import PgSQL
try:
cx = PgSQL.connect(...)
except PgSQL.DatabaseError, m:
print m # m will contain the error message from PostgreSQL.
I hope this helps.
--
____ | Billy G. Allie | Domain....: Bill.Allie at mug.org
| /| | 7436 Hartwell | MSN.......: B_G_Allie at email.msn.com
|-/-|----- | Dearborn, MI 48126|
|/ |LLIE | (313) 582-1540 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 1328 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20021229/ed2c26fe/attachment.sig>
More information about the Python-list
mailing list