You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
3.1 KiB

  1. import pyrebase
  2. config = {
  3. "apiKey": "AIzaSyD3bXRjLxEAVOKtj8hpjO4iI3Nn32F7agU",
  4. "authDomain": "foodcloud-f6eb1.firebaseapp.com",
  5. "databaseURL": "https://foodcloud-f6eb1.firebaseio.com/",
  6. "storageBucket": "foodcloud-f6eb1.appspot.com"
  7. }
  8. firebase = pyrebase.initialize_app(config)
  9. auth = firebase.auth()
  10. user = auth.sign_in_with_email_and_password('yigitcolakohlu@gmail.com', 'FoodWro2018')
  11. db = firebase.database()
  12. data_format_prod = {'Prod_Name': None, 'BBD': None, 'Nutrients': [], 'Calories': 0, 'Allergens': [],
  13. 'Problematic': False, 'Process': None, 'ED': None}
  14. data_format_proc = {'Harvested': {'Date': '', 'Location': '', 'Product': ''},
  15. 'Transport1': {'Duration': 0, 'Moved to,from': '-', 'Condition': True, 'Stopped': False},
  16. 'Process': {'Location': '', 'Processes': ''},
  17. 'Transport2': {'Duration': 0, 'Moved to,from': '-', 'Condition': 0, 'Stopped': False},
  18. 'Packaging': {'Location': '', 'Material': '', 'Cancerogen': True}}
  19. data_1_prod = {'Prod_Name': "Milk", 'BBD': "24.08.2018", 'Nutrients': ['Protein', 'Fat', 'Lactose', 'Glucose'],
  20. 'Calories': 120, 'Cooked': False, 'Allergens': ['Lactose'], 'Problematic': False,
  21. 'Process': 'Pastorized'}
  22. data_2_prod = {'Prod_Name': "Chocolate", 'BBD': "28.01.2019", 'Nutrients': ['Lactose', 'Glucose', 'Cocoa'],
  23. 'Calories': 180, 'Cooked': False, 'Allergens': [""], 'Problematic': False, 'Process': ''}
  24. data_1_proc = {'Harvested': {'Date': '18.08.2018', 'Location': 'Larson Family',
  25. 'Product': 'Raw Milk'},
  26. 'Transport1': {'Duration': 9, 'Moved to,from': 'Larson Family-McCarty Family Farms', 'Condition': True,
  27. 'Stopped': True}, 'Process': {'Location': 'McCarty Family Farms',
  28. 'Processes': 'Reverse Osmosis,Nanofiltration,Ultrafiltration,Microfiltration'},
  29. 'Transport2': {'Duration': 13, 'Moved to,from': 'McCarty Family Farms-JJX Packaging', 'Condition': True,
  30. 'Stopped': True},
  31. 'Packaging': {'Location': 'JJX Packaging', 'Material': 'Carton', 'Cancerogen': False}}
  32. data_2_proc = {'Harvested': {'Date': '27.01.2018', 'Location': 'India',
  33. 'Product': 'Cocoa'},
  34. 'Transport1': {'Duration': 71, 'Moved to,from': 'India-Nestle ', 'Condition': True, 'Stopped': True},
  35. 'Process': {'Location': 'Nestle', 'Processes': 'Roasting,Pulp,Conching,Moulding'},
  36. 'Transport2': {'Duration': 4, 'Moved to,from': 'Nestle-Ulma Packaging', 'Condition': True,
  37. 'Stopped': False},
  38. 'Packaging': {'Location': 'Ulma Packaging', 'Material': 'Foil', 'Cancerogen': False}}
  39. Products = [data_1_prod, data_2_prod]
  40. Processes = [data_1_proc, data_2_proc]
  41. for i in range(len(Products)):
  42. db.child("Products").child(str(i + 1)).set(Products[i])
  43. for i in range(len(Processes)):
  44. db.child("Processes").child(str(i + 1)).set(Processes[i])