Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
875 B
1
Indexable
Never
def admin_view_orders_with_status():
    try:
        cur.execute("SELECT Menu.ItemName, Orders.CustomerName, Orders.OrderDate, "
                    "Orders.Quantity, Orders.Packaging, COALESCE(Customer_Orders_Admin.Status, 'Pending') "
                    "FROM Orders "
                    "JOIN Menu ON Orders.ItemID = Menu.ItemID "
                    "LEFT JOIN Customer_Orders_Admin ON Orders.OrderID = Customer_Orders_Admin.OrderID")
        orders = cur.fetchall()
        if not orders:
            print("No orders with status found.")
            return

        table = PrettyTable(["Item Name", "Customer Name", "Order Date", "Quantity", "Packaging", "Status"])
        for order in orders:
            table.add_row(order)
        print(table)

    except mysql.connector.Error as err:
        print(f"Error: {err}")
        con.rollback()
Leave a Comment