Instance <ArticleEntity at 0x27701048> is not bound to a Session; attribute refresh operation cannot

 zhangy  2025-06-07 18:01:00  28  6  0

其实就是链接的session呗closed了

def save(self, model_entity):
    session = MySqlAccess.connection()
    try:
        session.add(model_entity)
        session.commit()
        return True    
    except Exception as e:
        print(e)
        session.rollback()
        return False    
    finally:
        session.close()


image.png


去掉就行了


作者禁止了评论
评论内容