sqlalchemy监听事件

@event.listens_for(db.Model, 'before_update', propagate=True)
def update_lasttime(mapper, connection, target):
    if hasattr(target, 'lasttime'):
        target.lasttime = datetime.now()

 

posted @ 2019-06-28 10:10  沈俊杰  阅读(861)  评论(0编辑  收藏  举报