示例#1
0
def delete(obj):
    """
    从数据库中删除一条数据
    :param obj: 要删除的对象
    :return:    成功或失败
    """
    with MyTransaction(db_session) as transaction:
        db_session.delete(obj)
    return transaction.status
示例#2
0
def delete_all(cls):
    """
    从数据库中删除一张表所有的数据
    :param cls: 数据表对应的类
    :return:    成功或失败
    """
    objs = query_all(cls)
    with MyTransaction(db_session) as transaction:
        for obj in objs:
            db_session.delete(obj)
    return transaction.status