@event.listens_for(mapper, 'init')
def auto_add(target, args, kwargs):
    Session.add(target)
Base = declarative_base()


class A(Base):
    __tablename__ = 'a'
id = Column(Integer, primary_key=True)
data = Column(String)
a1 = A(data='foo')
How to automatically add a SQLAlchemy object to the session?