Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
689 B
3
Indexable
def create_customer_orders_admin_table():
    try:
        cur.execute("CREATE TABLE IF NOT EXISTS Customer_Orders_Admin "
                    "(OrderID INT AUTO_INCREMENT PRIMARY KEY, ItemID INT, "
                    "CustomerName VARCHAR(255), OrderDate DATE, Quantity INT, Packaging VARCHAR(20), "
                    "Status VARCHAR(20), FOREIGN KEY (ItemID) REFERENCES Menu(ItemID))")

        cur.execute("INSERT INTO Customer_Orders_Admin (ItemID, CustomerName, OrderDate, Quantity, Packaging, Status) "
                    "SELECT * FROM Orders")

        con.commit()

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