Exemple #1
0
def query_by_upc(upc):
    """Get a product from the database by upc.
    Should be only one so grab the first one from the query result.

    :param str upc: product upc.
    """
    with app.app_context():
        product = dbapi.productTable().search_by_upc(upc)
    return product
Exemple #2
0
def query_by_upc(upc):
    """Get a product from the database by upc.
    Should be only one so grab the first one from the query result.

    :param str upc: product upc.
    """
    with app.app_context():
        product = dbapi.productTable().search_by_upc(upc)
    return product
Exemple #3
0
def query_price_range_search_db(manufacturer, price_low, price_high):
    """User can specify what items to lookup on Amazon from the database.
    User can choose manufacturer and a price range.
    Price range is optional.

    :param str manufacturer: the manufacturer to search for.
    :param float price_low: minimum price to search for
    :param float price_high: maximum price to search for
    """
    with app.app_context():
        if manufacturer:
            wildcard_manufacturer = '%' + manufacturer + '%'
            products = dbapi.productTable().search_by_price(
                price_low, price_high, wildcard_manufacturer)
        else:
            products = dbapi.productTable().search_by_price(
                price_low, price_high)
    return products
Exemple #4
0
def query_price_range_search_db(manufacturer, price_low, price_high):
    """User can specify what items to lookup on Amazon from the database.
    User can choose manufacturer and a price range.
    Price range is optional.

    :param str manufacturer: the manufacturer to search for.
    :param float price_low: minimum price to search for
    :param float price_high: maximum price to search for
    """
    with app.app_context():
        if manufacturer:
            wildcard_manufacturer = '%' + manufacturer + '%'
            products = dbapi.productTable().search_by_price(
                price_low,
                price_high,
                wildcard_manufacturer
            )
        else:
            products = dbapi.productTable().search_by_price(
                price_low,
                price_high
            )
    return products