[DB-SIG] General DB Error Handling
Andy Dustman
andy@dustman.net
26 Jun 2002 13:38:00 -0400
On Wed, 2002-06-26 at 11:37, Robert Theiss wrote:
> What I would like to do is trap any error returned
> from the database, so I can exit the program
> gracefully. A sample output is shown below, when I
> intentionally generate an SQL error.
Problem #1: Your module is compiled against the wrong version of Python.
It looks like it's compiled for 1.5.2 but you are using a 2.x version.
> InformixdbError: Error -522 performing PREPARE: Table
> (part) not selected in query.
> [bobt@monza:/service/bobt] >
>
> The python code that generated this output is shown
> below:
...
> try:
> returncode = apply(db.execute(SqlSelectStatement),
> args)
> except:
> print "return code is %s : " % args
You want:
c = db.cursor()
try:
c.execute(SqlSelectStatement, args) # return value undefined
rows = c.fetchall()
except InformixdbError, e:
print "return code is %s : " % e
--
Andy Dustman PGP: 0x930B8AB6
@ .net http://dustman.net/andy
"Cogito, ergo sum." -- Rene Descartes
"I yam what I yam and that's all what I yam." -- Popeye