[DB-SIG] General DB Error Handling
Tom Jenkins
tjenkins@devis.com
26 Jun 2002 11:38:15 -0400
On Wed, 2002-06-26 at 11:37, Robert Theiss wrote:
>
> [bobt@monza:/service/bobt] > python InfTest.py
> WARNING: Python C API version mismatch for module
> _informixdb:
> This Python has API version 1010, module _informixdb
> has version 1007.
> WARNING: Python C API version mismatch for module dbi:
> This Python has API version 1010, module dbi has
> version 1007.
> 20020626
> Traceback (most recent call last):
> File "InfTest.py", line 69, in ?
> db.execute(SqlSelectStatement)
> File
> "/opt/python/lib/python2.1/site-packages/informixdb.py",
> line 73, in execute
> return apply(self._cursor.execute, args)
> InformixdbError: Error -522 performing PREPARE: Table
> (part) not selected in query.
> [bobt@monza:/service/bobt] >
it looks like your informixdb.py catching the exception, dumping a stack
trace and never propagating the exception back to the app.
that's not good.
take a look at informixdb.py around line 73 and see
>
> The python code that generated this output is shown
> below:
>
> LocNbr = 96
> SqlSelectStatement = """
> select inv_audit.loc_nbr,
> extend(inv_audit.txn_datet, year to day),
> part.part_brand, part.part_nbr,
> part.part_desc,
> part.dealer_cost, inv_audit.avg_cost,
>
> inv_audit.qty_txn,
> inv_audit.user_id_created_by,
> inv_audit.inv_audit_info,
> inv_audit.txn_code, inv_audit.part_id
> from
> inv_audit
> where
> inv_audit.txn_type = 'RC' and
> inv_audit.txn_code = 'RE' and
> inv_audit.loc_nbr = %i and
> inv_audit.part_id = part.part_id;
> """ % LocNbr
> db.execute('set isolation dirty read;')
> # db.execute(SqlSelectStatement)
> try:
> returncode = apply(db.execute(SqlSelectStatement),
> args)
> except:
> print "return code is %s : " % args
>
> I'm sure this is basic python, but I've been banging
> my head against this wall for two days. This is
> simply my latest attempt.
> What I am looking for is a way to trap/report the
> informix -522 error that is shown above when the
> python module aborted.
>
> Any help is appreciated.
>
> Regards,
>
> Bob Theiss
> Programmer/Analyst
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
>
> _______________________________________________
> DB-SIG maillist - DB-SIG@python.org
> http://mail.python.org/mailman/listinfo/db-sig
--
Tom Jenkins
Development InfoStructure
http://www.devis.com