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()
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()
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()
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()
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