How to use the tblib.model.session.commit function in tblib

To help you get started, we’ve selected a few tblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shiyanlou / louplus-python / taobei / tbbuy / handlers / cart_product.py View on Github external
def delete_cart_product(id):
    """删除购物车商品
    """

    cart_product = CartProduct.query.filter(CartProduct.id == id).first()
    if cart_product is None:
        return json_response(ResponseCode.NOT_FOUND)

    session.delete(cart_product)
    session.commit()

    return json_response(cart_product=CartProductSchema().dump(cart_product))
github shiyanlou / louplus-python / taobei / tbbuy / handlers / order.py View on Github external
def create_order():
    """创建订单,订单商品需要一起提交
    """

    data = request.get_json()
    if data.get('pay_amount') is None:
        data['pay_amount'] = sum([x['price'] * x['amount']
                                  for x in data['order_products']])

    order = OrderSchema().load(data)
    session.add(order)
    session.commit()

    return json_response(order=OrderSchema().dump(order))
github shiyanlou / louplus-python / taobei / tbmall / handlers / favorite_product.py View on Github external
def create_favorite_product():
    """收藏商品
    """

    data = request.get_json()

    favorite_product = FavoriteProductSchema().load(data)
    session.add(favorite_product)
    session.commit()

    return json_response(favorite_product=FavoriteProductSchema().dump(favorite_product))
github shiyanlou / louplus-python / taobei / tbbuy / handlers / order_product.py View on Github external
def delete_order_product(order_id, product_id):
    order_product = OrderProduct.query.filter(and_(
        OrderProduct.order_id == order_id, OrderProduct.product_id == product_id)).first()
    if order_product is None:
        return json_response(ResponseCode.NOT_FOUND)
    session.delete(order_product)
    session.commit()

    return json_response(order_product=OrderProductSchema().dump(order_product))
github shiyanlou / louplus-python / taobei / tbuser / handlers / user.py View on Github external
def update_user(id):
    """更新用户
    """

    data = request.get_json()

    user = User.query.get(id)
    if user is None:
        return json_response(ResponseCode.NOT_FOUND)
    for key, value in data.items():
        setattr(user, key, value)
    session.commit()

    return json_response(user=UserSchema().dump(user))
github shiyanlou / louplus-python / taobei / challenge-02 / tbmall / handlers / product.py View on Github external
def create_product():
    """创建商品
    """

    data = request.get_json()

    product = ProductSchema().load(data)
    session.add(product)
    session.commit()

    return json_response(product=ProductSchema().dump(product))
github shiyanlou / louplus-python / taobei / tbmall / handlers / product.py View on Github external
def update_product(id):
    """更新商品
    """

    data = request.get_json()

    count = Product.query.filter(Product.id == id).update(data)
    if count == 0:
        return json_response(ResponseCode.NOT_FOUND)
    product = Product.query.get(id)
    session.commit()

    return json_response(product=ProductSchema().dump(product))