Exemplo n.º 1
0
    def get_products():
        """get request all products"""
        mycursor.execute("USE {}".format(DB_NAME))
        mycursor.execute(QUERY_GET_PRODS)
        myresult = mycursor.fetchall()

        print(
            tabulate(myresult,
                     headers=mycursor.column_names,
                     tablefmt='fancy_grid'))
Exemplo n.º 2
0
    def compare_by_score(nutri):
        """compare products with value (nutriscore superior or egal value)"""
        val = int(nutri)
        mycursor.execute("USE {}".format(DB_NAME))
        mycursor.execute(QUERY_COMPARE_SCORE + str(nutri))
        myresult = mycursor.fetchall()

        print(
            tabulate(myresult,
                     headers=mycursor.column_names,
                     tablefmt='fancy_grid'))
Exemplo n.º 3
0
    def search_by_name(value):
        """search product with value (name)"""
        val = str(value)
        mycursor.execute("USE {}".format(DB_NAME))
        mycursor.execute(QUERY_SEARCH_NAME, ("%" + val + "%", ))
        myresult = mycursor.fetchall()

        print(
            tabulate(myresult,
                     headers=mycursor.column_names,
                     tablefmt='fancy_grid'))
Exemplo n.º 4
0
    def get_prod(nutri):
        """get product with value (nutriscore)"""
        val = int(nutri)
        mycursor.execute("USE {}".format(DB_NAME))
        mycursor.execute(QUERY_GET_PROD_NUTRI + str(nutri))
        myresult = mycursor.fetchall()

        print(
            tabulate(myresult,
                     headers=mycursor.column_names,
                     tablefmt='fancy_grid'))