Naruto9 commited on
Commit
44836ef
1 Parent(s): c76d355

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -33
app.py CHANGED
@@ -96,6 +96,10 @@ if selected_page == "Order Management":
96
  'status': [status]
97
  })
98
  orders = pd.concat([orders, new_order], ignore_index=True)
 
 
 
 
99
 
100
  # Display order list
101
  st.write(orders)
@@ -120,6 +124,10 @@ elif selected_page == "Driver Management":
120
  'status': [status]
121
  })
122
  drivers = pd.concat([drivers, new_driver], ignore_index=True)
 
 
 
 
123
 
124
  # Display driver list
125
  st.write(drivers)
@@ -140,6 +148,10 @@ elif selected_page == "Zone Pressure":
140
  'pressure_level': [pressure_level]
141
  })
142
  zone_pressure = pd.concat([zone_pressure, new_zone_data], ignore_index=True)
 
 
 
 
143
 
144
  # Display zone pressure data
145
  st.write(zone_pressure)
@@ -166,47 +178,19 @@ elif selected_page == "Analytics":
166
  'customer_satisfaction': [customer_satisfaction]
167
  })
168
  analytics = pd.concat([analytics, new_analytics_data], ignore_index=True)
 
 
 
 
169
 
170
  # Display analytics information
171
  st.write(analytics)
172
 
173
-
174
  # Fetch initial data from the database
175
  drivers = fetch_data('drivers')
176
  orders = fetch_data('orders')
177
  zone_pressure = fetch_data('zone_pressure')
178
  analytics = fetch_data('analytics')
179
 
180
- # ... (within your form submission logic)
181
-
182
- # Instead of appending to DataFrames, insert into the database
183
- insert_data('orders', new_order.to_dict(orient='records')[0])
184
-
185
- # Re-fetch data to reflect the changes
186
- orders = fetch_data('orders')
187
-
188
-
189
- # Instead of appending to DataFrames, insert into the database
190
- insert_data('drivers', new_order.to_dict(orient='records')[0])
191
-
192
- # Re-fetch data to reflect the changes
193
- orders = fetch_data('drivers')
194
-
195
-
196
- # Instead of appending to DataFrames, insert into the database
197
- insert_data('zone_pressure', new_order.to_dict(orient='records')[0])
198
-
199
- # Re-fetch data to reflect the changes
200
- orders = fetch_data('zone_pressure')
201
-
202
-
203
- # Instead of appending to DataFrames, insert into the database
204
- insert_data('analytics', new_order.to_dict(orient='records')[0])
205
-
206
- # Re-fetch data to reflect the changes
207
- orders = fetch_data('analytics')
208
-
209
- # ... (similarly for other forms)
210
-
211
  # Close the database connection when the app is done
212
- st.session_state.on_session_end = conn.close
 
96
  'status': [status]
97
  })
98
  orders = pd.concat([orders, new_order], ignore_index=True)
99
+ # Insert into the database
100
+ insert_data('orders', new_order.to_dict(orient='records')[0])
101
+ # Re-fetch data to reflect the changes
102
+ orders = fetch_data('orders')
103
 
104
  # Display order list
105
  st.write(orders)
 
124
  'status': [status]
125
  })
126
  drivers = pd.concat([drivers, new_driver], ignore_index=True)
127
+ # Insert into the database
128
+ insert_data('drivers', new_driver.to_dict(orient='records')[0])
129
+ # Re-fetch data to reflect the changes
130
+ drivers = fetch_data('drivers')
131
 
132
  # Display driver list
133
  st.write(drivers)
 
148
  'pressure_level': [pressure_level]
149
  })
150
  zone_pressure = pd.concat([zone_pressure, new_zone_data], ignore_index=True)
151
+ # Insert into the database
152
+ insert_data('zone_pressure', new_zone_data.to_dict(orient='records')[0])
153
+ # Re-fetch data to reflect the changes
154
+ zone_pressure = fetch_data('zone_pressure')
155
 
156
  # Display zone pressure data
157
  st.write(zone_pressure)
 
178
  'customer_satisfaction': [customer_satisfaction]
179
  })
180
  analytics = pd.concat([analytics, new_analytics_data], ignore_index=True)
181
+ # Insert into the database
182
+ insert_data('analytics', new_analytics_data.to_dict(orient='records')[0])
183
+ # Re-fetch data to reflect the changes
184
+ analytics = fetch_data('analytics')
185
 
186
  # Display analytics information
187
  st.write(analytics)
188
 
 
189
  # Fetch initial data from the database
190
  drivers = fetch_data('drivers')
191
  orders = fetch_data('orders')
192
  zone_pressure = fetch_data('zone_pressure')
193
  analytics = fetch_data('analytics')
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  # Close the database connection when the app is done
196
+ st.session_state.on_session_end = conn.close