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.

82 lines
2.7 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 = {
  13. 'Prod_Name': None, 'BBD': None, 'Nutrients': [], 'Calories': 0, 'Allergens': [],
  14. 'Problematic': False, 'Process': None, 'ED': None
  15. }
  16. data_format_proc = {
  17. 'Harvested': {'Date': '', 'Location': '', 'Product': ''},
  18. 'Transport1': {'Duration': 0, 'Moved to,from': '-', 'Condition': True, 'Stopped': False},
  19. 'Process': {'Location': '', 'Processes': ''},
  20. 'Transport2': {'Duration': 0, 'Moved to,from': '-', 'Condition': 0, 'Stopped': False},
  21. 'Packaging': {'Location': '', 'Material': '', 'Cancerogen': True}
  22. }
  23. data_1_prod = {
  24. 'Prod_Name': "Milk", 'BBD': "24.08.2018", 'Nutrients': ['Protein', 'Fat', 'Lactose', 'Glucose'],
  25. 'Calories': 120, 'Cooked': False, 'Allergens': ['Lactose'], 'Problematic': False,
  26. 'Process': 'Pastorized'
  27. }
  28. data_2_prod = {
  29. 'Prod_Name': "Chocolate", 'BBD': "28.01.2019", 'Nutrients': ['Lactose', 'Glucose', 'Cocoa'],
  30. 'Calories': 180, 'Cooked': False, 'Allergens': [""], 'Problematic': False, 'Process': ''
  31. }
  32. data_1_proc = {
  33. 'Harvested': {
  34. 'Date': '18.08.2018', 'Location': 'Larson Family',
  35. 'Product': 'Raw Milk'
  36. },
  37. 'Transport1': {
  38. 'Duration': 9, 'Moved to,from': 'Larson Family-McCarty Family Farms', 'Condition': True,
  39. 'Stopped': True
  40. }, 'Process': {
  41. 'Location': 'McCarty Family Farms',
  42. 'Processes': 'Reverse Osmosis,Nanofiltration,Ultrafiltration,Microfiltration'
  43. },
  44. 'Transport2': {
  45. 'Duration': 13, 'Moved to,from': 'McCarty Family Farms-JJX Packaging', 'Condition': True,
  46. 'Stopped': True
  47. },
  48. 'Packaging': {'Location': 'JJX Packaging', 'Material': 'Carton', 'Cancerogen': False}
  49. }
  50. data_2_proc = {
  51. 'Harvested': {
  52. 'Date': '27.01.2018', 'Location': 'India',
  53. 'Product': 'Cocoa'
  54. },
  55. 'Transport1': {'Duration': 71, 'Moved to,from': 'India-Nestle ', 'Condition': True, 'Stopped': True},
  56. 'Process': {'Location': 'Nestle', 'Processes': 'Roasting,Pulp,Conching,Moulding'},
  57. 'Transport2': {
  58. 'Duration': 4, 'Moved to,from': 'Nestle-Ulma Packaging', 'Condition': True,
  59. 'Stopped': False
  60. },
  61. 'Packaging': {'Location': 'Ulma Packaging', 'Material': 'Foil', 'Cancerogen': False}
  62. }
  63. Products = [data_1_prod, data_2_prod]
  64. Processes = [data_1_proc, data_2_proc]
  65. for i in range(len(Products)):
  66. db.child("Products").child(str(i + 1)).set(Products[i])
  67. for i in range(len(Processes)):
  68. db.child("Processes").child(str(i + 1)).set(Processes[i])