[Zope] Capturing SQL Method exceptions in Python scripts
Dieter Maurer
dieter@handshake.de
Fri, 13 Dec 2002 22:34:39 +0100
Satheesh Babu writes:
> I've a python script in which I would like to call some SQL methods.
> Some SQL methods in question are DDL statements (alter table etc.). What
> I'm trying to do is to make an installer script for some patches.
>
> However, it is possible that the DDL statements might fail. How can I
> capture the exception type and process it?
>
> the zope-error pages come up like "sql.error: blah blah blah"
>
> try:
> ret = mysql()
> except sql.error, details
> print ...
>
> Normal python! But what should I REALLY use for sql.error ?
When I remember right (check the sources in "Shared/DC/ZRDB/DA.py"),
exceptions are not standardized by Z SQL Methods or (most)
Database adapters.
This means you will see most likely the exceptions of the Python-database
interface library.
These should be standardized. Consult the Python DB-API specification.
Dieter