예제 #1
0
def update_test():
    session = MySql().get_session()
    try:
        brands = session.query(Product).whereclause(Product.id == 1)
        for brand in brands:
            print(brand)
    except SQLAlchemyError as error:
        print(error)
    finally:
        session.close()
예제 #2
0
def read_test():
    session = MySql().get_session()
    try:
        products = session.query(Product).all()
        for product in products:
            print(product)
    except SQLAlchemyError as error:
        print(error)
    finally:
        session.close()
예제 #3
0
def update_test():
    session = MySql().get_session()
    try:
        brand = session.query(Brand).first()
        brand.name = 'TestBrandUpdate'
        session.commit()
    except SQLAlchemyError as error:
        print(error)
    finally:
        session.close()
예제 #4
0
def read_test():
    session = MySql().get_session()
    try:
        brands = session.query(Brand).all()
        for brand in brands:
            print(brand)
    except SQLAlchemyError as error:
        print(error)
    finally:
        session.close()
예제 #5
0
def delete_test():
    session = MySql().get_session()
    try:
        brand = session.query(Brand).first()
        session.delete(brand)
        session.commit()
    except SQLAlchemyError as error:
        print(error)
    finally:
        session.close()
    pass