我的程序不断收到以下错误:sqlite3.InterfaceError:绑定参数0时出错-可能是不支持类型

pjngdqdw  于 2022-12-13  发布在  SQLite
关注(0)|答案(1)|浏览(115)

我正在写一个应用程序,允许用户管理他们的客户条目。这是我写的代码的一部分。
我已经尝试了相当多,但无法摆脱以下错误:sqlite3.InterfaceError:绑定参数0时出错-可能是不支持类型
任何帮助将是可怕的,因为我是新的python和编码一般。
密码...

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
eit6fx6z

eit6fx6z1#

尝试将绑定参数转换为字符串。我怀疑,SQLite不接受UUID

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

相关问题