Skip to content

MathieuFerrandeau/Project5

Repository files navigation

Project 5: Use public data from OpenFoodFacts

This project uses openfoodfacts data to allow a user to choose from a product list a substitute with a nutriscore superior or equivalent to the chosen product.
As well as to save this substitute so as to retrieve the information that interest the user like the name, stores where to buy it and an url link with all the features of the product.

Database used: MYSQL

How to use it:

  1. Change FIELDS in config.py file with your own mysql credentials.
  2. Enter the following command in you console : pip install -r requirements.txt
  3. Enter the following command : python3 main.py -i (or --init) .
  4. And finally run the main.py file.

Once the connection is established the user has two possibilities:

  • Select from a list of 10 categories a product to have substitutes with a nutriscore equivalent or higher, to choose one and have the possibility to save it or not in its list of substitutes.
  • The possibility to consult its list of surrogates registered beforehand (empty if first connection).
  • Operation:

      sql.py:
    • In init we pass all the parameters of authenticity in parameter.
    • First method we use these parameters to create the database.
    • Second method we use all the parameters to connect to the database.
    • Third method we create the tables of the database with the .sql file.
      collect_data.py:
    • The first method retrieves API categories and insert 10 in the Category table.
    • The second method retrieves 20 products for each category from the Category table and inserts them into the Product table.
      init.py
    • The method allows you to initialize the database with the methods of classes Sql and CollectData (from creation to filling).
      program.py:
    • The first method displays the 10 categories.
    • The second method displays 20 products according to the chosen category
    • The third method is to display a substitute that has a nutrient equivalent or greater than the product previously selected with the possibility to save it in the database or not.
    • The fourth method allows the user once all completed steps to return to the main menu or exit the application.
    • Finally the last method allows the user to consult his list of registered surrogates (empty if first use).
      main.py:
    • The main file can be called two ways, the first using an argument (-i or --init) will create and fill the database thanks to the class Init. And the second, by executing it without argument, it will launch the application that will allow the interaction between the user and the program.

    About

    Utilisez les données publiques de l'OpenFoodFacts

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published