[DB-SIG] Exeception Handling.

2008-07-04 Thread Heston James - Cold Beans
Good afternoon Chaps, I'm looking for your advice on the best way to handle exceptions on a query and commit. Within my application I have a universal database connection which gets injected into objects which require database access, I then use this connection to create cursors, run queries an

Re: [DB-SIG] Exeception Handling.

2008-07-04 Thread M.-A. Lemburg
On 2008-07-04 12:34, Heston James - Cold Beans wrote: Good afternoon Chaps, I'm looking for your advice on the best way to handle exceptions on a query and commit. Within my application I have a universal database connection which gets injected into objects which require database access, I t

Re: [DB-SIG] Exeception Handling.

2008-07-04 Thread Heston James - Cold Beans
> I'd put the whole transaction code into a try-except: > > try: > # Start of transaction > ... do stuff ... > except Exception: > self.datasource.rollback() > raise > else: > self.datasource.commit() > > This assures that a successful execution of your code results in > th

Re: [DB-SIG] Exeception Handling.

2008-07-04 Thread M.-A. Lemburg
On 2008-07-04 14:03, Heston James - Cold Beans wrote: I'd put the whole transaction code into a try-except: try: # Start of transaction ... do stuff ... except Exception: self.datasource.rollback() raise else: self.datasource.commit() This assures that a successful exec

Re: [DB-SIG] Exeception Handling.

2008-07-04 Thread M.-A. Lemburg
On 2008-07-04 14:22, M.-A. Lemburg wrote: On 2008-07-04 14:03, Heston James - Cold Beans wrote: I'd put the whole transaction code into a try-except: try: # Start of transaction ... do stuff ... except Exception: self.datasource.rollback() raise else: self.datasource.co