-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
221 lines (198 loc) · 10.9 KB
/
data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#uselsess imo
import mysql.connector
db_config = {
'host': 'localhost',
'user': 'root',
'password': 'Aditya@06',
'database': 'food', # Replace with your database name
}
# Connect to the database
connection = mysql.connector.connect(**db_config)
if connection.is_connected():
print("Connected to MySQL database")
query="""INSERT INTO Recipient(Email_ID,Recipient_ID,
NGO_name,Phone_number,Address,City,State,Pincode,
Quantity_required_in_grams,Redistribution_time_span_in_hours)
VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"""
new_rows_data = [
(41, 'Gravy food', 41, 'butter chicken', 750, '2023-11-05', '2023-10-25',
'Chicken,Butter,Heavy Cream,Tomato Sauce,Spices', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'store in cold place', 'Available', 36),
(42, 'Rice', 42, 'saffron rice', 600, '2023-11-08', '2023-10-30',
'Basmati Rice,Saffron Threads,Onions,Ghee,Spices', 5,
'None', 'Vegetarian', 'store in dry place', 'Available', 16),
(43, 'Pasta', 43, 'carbonara', 450, '2023-11-12', '2023-11-01',
'Spaghetti,Heavy Cream,Eggs,Bacon,Parmesan Cheese,Black Pepper', 6,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 20),
(44, 'Seafood', 44, 'grilled shrimp', 550, '2023-11-18', '2023-11-10',
'Shrimp,Garlic,Butter,Lemon Juice,Parsley', 5,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 15),
(45, 'Salad', 45, 'Greek salad', 400, '2023-11-22', '2023-11-15',
'Cucumber,Tomato,Olives,Feta Cheese,Olive Oil', 5,
'None', 'Vegetarian', 'keep refrigerated', 'Available', 10),
(46, 'Rice', 46, 'fried rice', 800, '2023-11-28', '2023-11-20',
'Rice,Shrimp,Peas,Carrots,Eggs,Soy Sauce', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 30),
(47, 'Pasta', 47, 'alfredo pasta', 500, '2023-12-02', '2023-11-25',
'Fettuccine Pasta,Heavy Cream,Butter,Parmesan Cheese,Garlic', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 22),
(48, 'Gravy food', 48, 'beef stew', 700, '2023-12-08', '2023-12-01',
'Beef,Carrots,Potatoes,Onions,Beef Broth,Flour', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 25),
(49, 'Dry food', 49, 'couscous salad', 350, '2023-12-12', '2023-12-05',
'Couscous,Cherry Tomatoes,Cucumbers,Parsley,Red Onion', 5,
'None', 'Vegetarian', 'store in dry place', 'Available', 10),
(50, 'Salad', 50, 'spinach salad', 450, '2023-12-18', '2023-12-10',
'Baby Spinach,Strawberries,Goat Cheese,Walnuts,Balsamic Vinaigrette', 5,
'Contains nuts', 'Vegetarian', 'keep refrigerated', 'Available', 18),
(51, 'Pasta', 51, 'lasagna', 600, '2023-12-22', '2023-12-15',
'Lasagna Noodles,Ground Beef,Ricotta Cheese,Mozzarella Cheese,Tomato Sauce', 6,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 32),
(52, 'Rice', 52, 'mushroom rice', 500, '2023-12-28', '2023-12-20',
'Rice,Mushrooms,Onions,Chicken Broth,Butter', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 14),
(53, 'Gravy food', 53, 'lamb curry', 750, '2024-01-02', '2023-12-25',
'Lamb,Onions,Tomatoes,Garlic,Ginger,Spices', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 38),
(54, 'Chicken', 54, 'chicken curry', 700, '2024-01-08', '2024-01-01',
'Chicken,Onions,Tomatoes,Garlic,Ginger,Spices', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 35),
(55, 'Salad', 55, 'fruit salad', 600, '2024-01-12', '2024-01-05',
'Apple,Banana,Orange,Grapes,Honey,Nuts', 6,
'None', 'Vegetarian', 'keep refrigerated', 'Available', 28),
(56, 'Rice', 56, 'sushi rice', 450, '2024-01-18', '2024-01-10',
'Sushi Rice,Rice Vinegar,Sugar,Salt', 4,
'None', 'Vegetarian', 'store in dry place', 'Available', 12),
(57, 'Pasta', 57, 'mac and cheese', 500, '2024-01-22', '2024-01-15',
'Elbow Macaroni,Cheddar Cheese,Butter,Flour,Milk', 5,
'Contains dairy dietary', 'Vegetarian', 'keep refrigerated', 'Available', 22),
(58, 'Gravy food', 58, 'beef stroganoff', 750, '2024-01-28', '2024-01-20',
'Beef,Onions,Mushrooms,Beef Broth,Sour Cream', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 30),
(59, 'Rice', 59, 'jambalaya', 600, '2024-02-02', '2024-01-25',
'Rice,Chicken,Shrimp,Andouille Sausage,Onions,Celery,Bell Peppers', 7,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 45),
(60, 'Pasta', 60, 'ravioli', 400, '2024-02-08', '2024-02-01',
'Ravioli (Cheese Filling),Marinara Sauce,Parmesan Cheese', 4,
'Contains dairy dietary', 'Vegetarian', 'keep refrigerated', 'Available', 18),
]
# Create a cursor to execute SQL statements
cursor = connection.cursor()
# SQL statement to insert rows
insert_query = """
INSERT INTO Surplus (Food_id, food_type, donor_id, food_name, quantity_in_grams, Expiry_Date, Packaging_Date, ingredients, ingredient_count, Allergen_Info, Dietary_Info, storage_remarks, status, waste_in_grams)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
try:
# Insert the new rows into the table
cursor.executemany(insert_query, new_rows_data)
# Commit the changes
connection.commit()
print(f"Inserted {len(new_rows_data)} rows successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
# Rollback the transaction if an error occurs
connection.rollback()
finally:
# Close the cursor and connection
cursor.close()
connection.close()
'''
# Database configuration
db_config = {
'host': 'localhost',
'user': 'root',
'password': '@MYsql23!',
'database': 'Food', # Replace with your database name
}
# Connect to the database
connection = mysql.connector.connect(**db_config)
if connection.is_connected():
print("Connected to MySQL database")
# Define the data for the 25 new rows (modify as needed)
# Define the data for the 25 new rows (modify as needed)
# Additional rows of data starting from the 41st row
new_rows_data = [
(41, 'Gravy food', 41, 'butter chicken', 750, '2023-11-05', '2023-10-25',
'Chicken,Butter,Heavy Cream,Tomato Sauce,Spices', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'store in cold place', 'Available', 36),
(42, 'Rice', 42, 'saffron rice', 600, '2023-11-08', '2023-10-30',
'Basmati Rice,Saffron Threads,Onions,Ghee,Spices', 5,
'None', 'Vegetarian', 'store in dry place', 'Available', 16),
(43, 'Pasta', 43, 'carbonara', 450, '2023-11-12', '2023-11-01',
'Spaghetti,Heavy Cream,Eggs,Bacon,Parmesan Cheese,Black Pepper', 6,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 20),
(44, 'Seafood', 44, 'grilled shrimp', 550, '2023-11-18', '2023-11-10',
'Shrimp,Garlic,Butter,Lemon Juice,Parsley', 5,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 15),
(45, 'Salad', 45, 'Greek salad', 400, '2023-11-22', '2023-11-15',
'Cucumber,Tomato,Olives,Feta Cheese,Olive Oil', 5,
'None', 'Vegetarian', 'keep refrigerated', 'Available', 10),
(46, 'Rice', 46, 'fried rice', 800, '2023-11-28', '2023-11-20',
'Rice,Shrimp,Peas,Carrots,Eggs,Soy Sauce', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 30),
(47, 'Pasta', 47, 'alfredo pasta', 500, '2023-12-02', '2023-11-25',
'Fettuccine Pasta,Heavy Cream,Butter,Parmesan Cheese,Garlic', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 22),
(48, 'Gravy food', 48, 'beef stew', 700, '2023-12-08', '2023-12-01',
'Beef,Carrots,Potatoes,Onions,Beef Broth,Flour', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 25),
(49, 'Dry food', 49, 'couscous salad', 350, '2023-12-12', '2023-12-05',
'Couscous,Cherry Tomatoes,Cucumbers,Parsley,Red Onion', 5,
'None', 'Vegetarian', 'store in dry place', 'Available', 10),
(50, 'Salad', 50, 'spinach salad', 450, '2023-12-18', '2023-12-10',
'Baby Spinach,Strawberries,Goat Cheese,Walnuts,Balsamic Vinaigrette', 5,
'Contains nuts', 'Vegetarian', 'keep refrigerated', 'Available', 18),
(51, 'Pasta', 51, 'lasagna', 600, '2023-12-22', '2023-12-15',
'Lasagna Noodles,Ground Beef,Ricotta Cheese,Mozzarella Cheese,Tomato Sauce', 6,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 32),
(52, 'Rice', 52, 'mushroom rice', 500, '2023-12-28', '2023-12-20',
'Rice,Mushrooms,Onions,Chicken Broth,Butter', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 14),
(53, 'Gravy food', 53, 'lamb curry', 750, '2024-01-02', '2023-12-25',
'Lamb,Onions,Tomatoes,Garlic,Ginger,Spices', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 38),
(54, 'Chicken', 54, 'chicken curry', 700, '2024-01-08', '2024-01-01',
'Chicken,Onions,Tomatoes,Garlic,Ginger,Spices', 6,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 35),
(55, 'Salad', 55, 'fruit salad', 600, '2024-01-12', '2024-01-05',
'Apple,Banana,Orange,Grapes,Honey,Nuts', 6,
'None', 'Vegetarian', 'keep refrigerated', 'Available', 28),
(56, 'Rice', 56, 'sushi rice', 450, '2024-01-18', '2024-01-10',
'Sushi Rice,Rice Vinegar,Sugar,Salt', 4,
'None', 'Vegetarian', 'store in dry place', 'Available', 12),
(57, 'Pasta', 57, 'mac and cheese', 500, '2024-01-22', '2024-01-15',
'Elbow Macaroni,Cheddar Cheese,Butter,Flour,Milk', 5,
'Contains dairy dietary', 'Vegetarian', 'keep refrigerated', 'Available', 22),
(58, 'Gravy food', 58, 'beef stroganoff', 750, '2024-01-28', '2024-01-20',
'Beef,Onions,Mushrooms,Beef Broth,Sour Cream', 5,
'Contains dairy dietary', 'Non-Vegetarian', 'keep refrigerated', 'Available', 30),
(59, 'Rice', 59, 'jambalaya', 600, '2024-02-02', '2024-01-25',
'Rice,Chicken,Shrimp,Andouille Sausage,Onions,Celery,Bell Peppers', 7,
'None', 'Non-Vegetarian', 'store in cold place', 'Available', 45),
(60, 'Pasta', 60, 'ravioli', 400, '2024-02-08', '2024-02-01',
'Ravioli (Cheese Filling),Marinara Sauce,Parmesan Cheese', 4,
'Contains dairy dietary', 'Vegetarian', 'keep refrigerated', 'Available', 18),
]
# Create a cursor to execute SQL statements
cursor = connection.cursor()
# SQL statement to insert rows
insert_query = """
INSERT INTO Surplus (Food_id, food_type, donor_id, food_name, quantity_in_grams, Expiry_Date, Packaging_Date, ingredients, ingredient_count, Allergen_Info, Dietary_Info, storage_remarks, status, waste_in_grams)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
try:
# Insert the new rows into the table
cursor.executemany(insert_query, new_rows_data)
# Commit the changes
connection.commit()
print(f"Inserted {len(new_rows_data)} rows successfully.")
except mysql.connector.Error as err:
print(f"Error: {err}")
# Rollback the transaction if an error occurs
connection.rollback()
finally:
# Close the cursor and connection
cursor.close()
connection.close()
'''