Home > database >  My program keeps getting the following error: sqlite3.InterfaceError: Error binding parameter 0 - pr
My program keeps getting the following error: sqlite3.InterfaceError: Error binding parameter 0 - pr

Time:12-06

I am writing an application that allows the user to manage their customer entries. This is one part of the code I have written.

I have tried quite a bit but cannot get rid of the following error: sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.

Any help would be awesome as I am new to python and coding in general.

Code...

def customer_creation_process():

#This function initiates the customer creation process by asking details from the user about their customer.

    customer_forename = input("Please enter the customer's forename.\n").strip(' ')
    customer_surname = input("Please enter the customer's surname.\n").strip(' ')
    customer_dob = input("Please enter the customer's date of birth. Please ensure this is in the             following format:22/07/2002\n").strip(' ')
    print("Generating Unique Customer ID...")
    customer_id = uuid.uuid4()
    print("Generating and Inserting Customer Details Into your System...")
    insert_customer_details(customer_id, customer_forename, customer_surname, customer_dob)
    time.sleep(2)
    print(f"The following details have been recorded: {customer_id}, {customer_forename}, {customer_surname}, {customer_dob}")
   
        
#Seperate function to insert given customer details into customer table within database

def insert_customer_details(customer_id, customer_forename, customer_surname, customer_dob):
"""This function inserts the customer details into the database"""
    cursor = connection.cursor()
    cursor.execute("INSERT INTO customer VALUES (?, ?, ?, ?)" , (customer_id, customer_forename, customer_surname, customer_dob))
    connection.commit()
    return

CodePudding user response:

Try to convert your bind parameters to strings. I suspect, SQLite does not accept UUID

cursor.execute("INSERT INTO customer VALUES (?, ?, ?, ?)" , (str(customer_id), str(customer_forename), str(customer_surname), str(customer_dob)))
  • Related