Re: [cx-oracle-users] Extracting Oracle error codes, characterizing exceptions
Brought to you by:
atuining
From: Anthony T. <an...@co...> - 2004-02-17 15:03:57
|
The only other interesting piece of information might be the following: Python exceptions have an "args" attribute which in this case is a singleton tuple containing an error info object. This error info object has three attributes: code - the numeric Oracle code message - the message that is obtained via str(exceptionValue) context - the context in which the error was raised As to your other question about the fact that cx_Oracle always raises DatabseError when it would seem more reasonable to return something like DataError -- I haven't gone to the trouble of creating a mapping between Oracle errors and DB API errors. Someone (possibly on this list) said they were going to send me patches for this but I haven't heard from them in several months so perhaps not.... If you would like to pick up that ball, I'm quite willing to accept patches. :-) Otherwise, I have other things which I would like to do that I would consider higher priority... :-) On Tue, 2004-02-17 at 04:30, ????? ???? wrote: > Hi, > > > > Try like in this > short example: > > > ------------------------------------------------<cut>----------------------- > -------------------- > try: > my_connection=cx_Oracle.connect('system/manager@test_db') > except cx_Oracle.DatabaseError,info: > print "Logon Error:",info > exit(0) > > my_cursor=my_connection.cursor() > try: > my_cursor.execute(""" > SELECT ROWID,O.* FROM TESTER.PODR O """) > except cx_Oracle.DatabaseError,info: > print "SQL Error:",info > exit(0) > ------------------------------<end cut > >------------------------------------- > > > Best regards, > > Oleg Popov > op...@ya... > > > ----- Original Message ----- > From: "Jeff Wong" <jef...@sa...> > To: <cx-...@li...> > Sent: Monday, February 16, 2004 11:41 PM > Subject: [cx-oracle-users] Extracting Oracle error codes, characterizing > exceptions > > > > Is there way to extract Oracle error codes other than by applying str() to > > the exception and parsing the string? > > > > Also, if I cannot connect to the Oracle database would that be a > > DatabaseError or an InternalError? > > > > I am trying to use cx_Oracle to write a server that needs to be reliable > > and I am trying to figure out how to handle possible exceptions returned > > from Oracle. > > > > I also noticed that violations of table constraints are DatabaseErrors, > > rather than DataErrors. Is this intended? What are examples of > > DataErrors? > > > > Thanks, > > > > Jeff > > > > > > > > > > > > > > ------------------------------------------------------- > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > > Build and deploy apps & Web services for Linux with > > a free DVD software kit from IBM. Click Now! > > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > > _______________________________________________ > > cx-oracle-users mailing list > > cx-...@li... > > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users -- Anthony Tuininga an...@co... Computronix Distinctive Software. Real People. Suite 200, 10216 - 124 Street NW Edmonton, AB, Canada T5N 4A3 Phone: (780) 454-3700 Fax: (780) 454-3838 http://www.computronix.com |