I'm developing a zope app that uses an external database (Postgres) for its back end. It works great when it's working, but if there's an error, I don't know how to print the error message. I can't find any documentation on how to get the sql error that was generated by the database. That makes debugging very time consuming. The only example I could find just uses a generic dtml exception handler, which doesn't print the error string. Does anyone have any docs/examples on this? Thanks! -- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F
<dtml-try> <dtml-in select> <dtml-var show> </dtml-in> <dtml-except> <dtml-var error_value> </dtml-try> If there's an SQL error raised by PostgreSQL, you'll get the error message in error_value. If you don't use the try/except wrap, Zope will raise an error which shows the PG error. Zope 2.5.0; PG 7.3cvs (but should be the same w/earlier versions of PG). I'm using zpysopg; this might be quite different with other PG adapters. Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton Knowledge Management & Technology Consultant
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Colin Fox Sent: Monday, March 18, 2002 10:51 PM To: zope@zope.org Subject: [Zope] ZSQL Errors
I'm developing a zope app that uses an external database (Postgres) for its back end. It works great when it's working, but if there's an error, I don't know how to print the error message.
I can't find any documentation on how to get the sql error that was generated by the database. That makes debugging very time consuming.
The only example I could find just uses a generic dtml exception handler, which doesn't print the error string.
Does anyone have any docs/examples on this?
Thanks!
-- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F
Thanks - I'm also using zpsycopg. This is exactly what I was looking for! Is this documented anywhere, or is this a new feature? On Tue, 2002-03-19 at 07:50, Joel Burton wrote:
<dtml-try> <dtml-in select> <dtml-var show> </dtml-in> <dtml-except> <dtml-var error_value> </dtml-try>
If there's an SQL error raised by PostgreSQL, you'll get the error message in error_value. If you don't use the try/except wrap, Zope will raise an error which shows the PG error.
Zope 2.5.0; PG 7.3cvs (but should be the same w/earlier versions of PG). I'm using zpysopg; this might be quite different with other PG adapters.
-- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F
Neither. It's nothing specific to ZSQLMethods; in a try/except context, the errors for everything (all Zope errors, not just DB errors) are put in error_value. See the help for the dtml-try tag for other info. Glad to have helped. Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton Knowledge Management & Technology Consultant
-----Original Message----- From: Colin Fox [mailto:cfox@crystalcherry.com] Sent: Wednesday, March 20, 2002 8:03 PM To: Joel Burton Cc: zope@zope.org Subject: RE: [Zope] ZSQL Errors
Thanks - I'm also using zpsycopg. This is exactly what I was looking for!
Is this documented anywhere, or is this a new feature?
On Tue, 2002-03-19 at 07:50, Joel Burton wrote:
<dtml-try> <dtml-in select> <dtml-var show> </dtml-in> <dtml-except> <dtml-var error_value> </dtml-try>
If there's an SQL error raised by PostgreSQL, you'll get the error message in error_value. If you don't use the try/except wrap, Zope will raise an error which shows the PG error.
Zope 2.5.0; PG 7.3cvs (but should be the same w/earlier versions of PG). I'm using zpysopg; this might be quite different with other PG adapters.
-- Colin Fox cfox@crystalcherry.com CF Consulting Inc. GPG Fingerprint: D8F0 84E7 E7CC 5C6C 9982 F1A7 A3EB 6EA3 BC97 572F
participants (2)
-
Colin Fox -
Joel Burton