admin.py changes

mail@pastecode.io avatar
unknown
python
7 months ago
952 B
2
Indexable
Never
#admin.py

mcursor.execute("""CREATE TABLE IF NOT EXISTS clients (
                clientid INT AUTO_INCREMENT PRIMARY KEY,
                clientname VARCHAR(50),
                clientnumber VARCHAR(50),
                clientemail VARCHAR(50),
                typeofevent VARCHAR(50))""")

def addclient():
    try:
        clientname = input("Enter client's full name: ")
        clientnumber = input("Enter client's contact number: ")
        clientemail = input("Enter client's email: ")
        typeofevent = input("Enter the event the client wants to host: ")

        query = "INSERT INTO clients (clientname, clientnumber, clientemail, typeofevent) VALUES (%s, %s, %s, %s)"
        values = (clientname, clientnumber, clientemail, typeofevent)

        mcursor.execute(query, values)
        mydb.commit()

        print("Client added successfully!")

    except mp.Error as e:
        print("Error adding client:", e)
        mydb.rollback()
Leave a Comment