Hell
Hell
connector
try:
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor()
print(f"Error: {err}")
exit(1)
def show_menu():
menu_items = cursor.fetchall()
def add_menu_item():
cursor.execute("INSERT INTO menu (name, price) VALUES (%s, %s)", (name, price))
conn.commit()
def place_order():
"""Place a new order."""
show_menu()
price = cursor.fetchone()
if not price:
return
cursor.execute(
"INSERT INTO orders (customer_name, menu_item_id, quantity, total_price) VALUES (%s, %s,
%s, %s)",
conn.commit()
def view_orders():
cursor.execute("""
FROM orders o
""")
orders = cursor.fetchall()
print(f"Order ID: {order[0]}, Customer: {order[1]}, Item: {order[2]}, Quantity: {order[3]}, "
def update_order_status():
view_orders()
print("Invalid status.")
return
conn.commit()
def main():
while True:
print("6. Exit")
if choice == '1':
show_menu()
add_menu_item()
elif choice == '3':
place_order()
view_orders()
update_order_status()
print("Exiting. Goodbye!")
break
else:
if __name__ == "__main__":
main()