[DB-SIG] newbie question on trapping a DB error message using psycopg2 / DB-API
Chris Wood
chris.wood at bookitnow.ca
Sat Oct 4 00:00:59 CEST 2008
If I run a python program that calls a stored procedure without a "try:" ,
I see a descriptive message in the error that is returned (highlighted
inyellowbelow):
>>> cur.execute("select * from f_test_return_error2('normon')")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/psycopg2/extras.py", line 48, in
execute
return _cursor.execute(self, query, vars, async)
psycopg2.ProgrammingError: Error. Party name normon not found in the party
table.
but if I put the "cur.execute" in a "try:" / "except:" I cannot figure out
where to get the error text that I need,
can anyone help please??
I know it is possible because a friend of mine can get it back from
SQLAlchemy and SQLAlchemy uses psycopg2.
thanks,
- chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20081003/543c23a3/attachment.htm>
More information about the DB-SIG
mailing list