well the begin() in this case is doing a flush() of pending data to ensure that it starts clean - otherwise if you said rollback(), the state which to roll back to would not be determined. then since you have autocommit=True its issuing a COMMIT. so a COMMIT is happening and if you have things that need to occur on COMMIT, they need to occur there.
If you want to turn all of the 0.5 behavior off you can use a flag called _enable_transaction_accounting=False, which will prevent rollback() from being recoverable. I would recommend not using autocommit=True at all, however, instead just ensure the session is rolled back or committed after a unit of work. also with PG ill often just dump off other connections if i need to do database migrations. On May 24, 2009, at 4:01 AM, Alessandro Dentella wrote: > from sqlalchemy.ext.declarative import declarative_base > from sqlalchemy import Table, Column, ForeignKey, text, func > from sqlalchemy.orm import sessionmaker, mapper, relation > from sqlalchemy.orm.interfaces import SessionExtension > from sqlalchemy.types import * > > Base = declarative_base() > Base.metadata.bind = 'sqlite://' > > class SKSessionExtension(SessionExtension): > > def after_commit(self, session): > print "Whithin SessionExtension 'after_commit'" > > > Session = sessionmaker(bind=Base.metadata.bind, > expire_on_commit=True, > autoflush=False, > autocommit=True, > extension=SKSessionExtension(), > ) > sess = Session() > > class Status(Base): > __tablename__ = 'ticket_status' > id = Column(Integer, primary_key=True) > status = Column(String(20)) > > Base.metadata.create_all() > > s = Status() > s.status = "test" > sess.add(s) > > print "BEGIN" > sess.begin() > print "COMMIT" > sess.commit() --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
