0

I am asking for the customer's ID to check if they're in the table, however I 1) Don't know if I'm going about it right and 2) Keep getting a value error

def place_order():
    custid_Sorder = int(input("Please enter your customer ID: "))
    custid_query = "SELECT * FROM Customer WHERE CustomerID=?"
    cursor.execute(custid_query, custid_Sorder)
    result_po = cursor.fetchall()
    connection.commit()
    temp = False
    for x in result_po:
        if custid_Sorder in x:
            temp = True
    if temp:
        print("Welcome to our Christmas store! This is all of our stock;")
        cursor.execute("SELECT * FROM Inventory")
        stock = cursor.fetchall()
        for row in stock:
            print(row)
        buy_another_flag = 1
        while buy_another_flag != 0:
            option = int(input("Enter the ID of the item you would like to order: "))
            option_quant = int(input("Enter quantity: "))
       

Whenever I input customer id this comes up;

cursor.execute(custid_query, custid_Sorder)
ValueError: parameters are of unsupported type

1 Answers1

0

Try this

custid_query = "SELECT * FROM Customer WHERE CustomerID=?"
cursor.execute(custid_query, [custid_Sorder])

If you are using psycopg (postgres) you can also do this

custid_query = "SELECT * FROM Customer WHERE CustomerID = %s"
cursor.execute(custid_query, (custid_Sorder,))