Hi, I am having problems getting transactions working.
I am calling conn.begin() but before I call trans.commit(), something else commits for me. It is committing right after I do the job_insert.execute(). Can someone shed some light. Many Thanks Huy I have the following code trans = db.engine.contextual_connect().begin try: for client_id in slist.keys(): job_insert.execute( ) job_id = engine.func.currval('job_id_seq').scalar() for r in rows: service_insert.execute( ) trans.commit() self.error('Storage Period Charged Successfully. You can now proceed with Invoicing') return self.redirect('/invoice') except: self.error(sys.exc_info()[1]) trans.rollback() return self.render('storage_charge.mak') and the following SQL generated sqlalchemy.engine.base.Engine.0x..f0 BEGIN sqlalchemy.engine.base.Engine.0x..f0 select nextval('"job_id_seq"') sqlalchemy.engine.base.Engine.0x..f0 None sqlalchemy.engine.base.Engine.0x..f0 INSERT INTO job (id, j ob_type, client_reference, client_id, is_complete, complete_date, warehouse_code, update d_by) VALUES (%(id)s, %(job_type)s, %(client_reference)s, %(client_id)s, %(is_complete)s , %(complete_date)s, %(warehouse_code)s, %(updated_by)s) sqlalchemy.engine.base.Engine.0x..f0 {'updated_by': 'admin' , 'job_type': 'STO', 'id': 31L, 'warehouse_code': 'syd1', 'client_id': 19, 'complete_dat e': datetime.date(2007, 4, 20), 'is_complete': True, 'client_reference': '02-04-2007- 08 -04-2007'} sqlalchemy.engine.base.Engine.0x..f0 COMMIT sqlalchemy.engine.base.Engine.0x..f0 SELECT currval(%(currval)s) sqlalchemy.engine.base.Engine.0x..f0 {'currval': 'job_id_seq'} sqlalchemy.engine.base.Engine.0x..f0 select nextval('"service_id_seq"') sqlalchemy.engine.base.Engine.0x..f0 None sqlalchemy.engine.base.Engine.0x..f0 INSERT INTO service (i d, service_code, service_amt, quantity, updated_by, client_id, description, job_id, date , rate_amt) VALUES (%(id)s, %(service_code)s, %(service_amt)s, %(quantity)s, %(updated_b y)s, %(client_id)s, %(description)s, %(job_id)s, %(date)s, %(rate_amt)s) 2007-04-20 01:46:51,546 INFO sqlalchemy.engine.base.Engine.0x..f0 {'description': None, 'service_code': 'O/S', 'service_amt': Decimal("187.50"), 'updated_by': 'admin', 'rate_am t': Decimal("12.50"), 'client_id': 19, 'date': datetime.date(2007, 4, 8), 'quantity': 15 L, 'id': 21723L, 'job_id': 31L} sqlalchemy.engine.base.Engine.0x..f0 ROLLBACK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---