Когда я запускаю свой код, я получаю сообщение об ошибке «sqlite3.IntegrityError: Несоответствие типа данных». Я считаю, что это связано с базой данных, но я не могу найти ошибку. Я проверил, допустил ли я, что внешний ключ определенного типа данных ссылается на атрибут другого типа данных, но все еще не может найти ошибку. Вот моя база данных:
import sqlite3
connection = sqlite3.connect('database.db')
cursor = connection.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS tblCustomer (
customerID TEXT (6),
firstName TEXT (10),
secondName TEXT (15),
dob DATE,
address TEXT,
telephone INT (11),
primary key (customerID)
)""")
tblCustomer = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblEmployee (
employeeID TEXT (6),
firstName TEXT (10),
secondName TEXT (15),
dob DATE,
address TEXT,
telephone INT (11),
gender TEXT,
role TEXT,
salary INT,
primary key (employeeID)
)""")
tblEmployee = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblBooking (
bookingID TEXT (6),
checkInDate DATE,
checkOutDate DATE,
numberOfOccupants INT,
customerID TEXT,
roomID TEXT,
primary key (bookingID),
foreign key (customerID) REFERENCES tblCustomer(customerID),
foreign key (roomID) REFERENCES tblRoomAllocation(roomID)
)""")
tblBooking = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblRoomAllocation (
roomID TEXT (6),
roomType TEXT (20),
DateAdded DATE,
DateVacated DATE,
housekeepingID TEXT,
primary key (roomID),
foreign key (housekeepingID) REFERENCES tblHousekeeping(housekeepingID)
)""")
tblRoomAllocation = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblHousekeeping (
housekeepingID TEXT (6),
dob DATE,
assignedTo TEXT (20),
primary key (housekeepingID)
)""")
tblHousekeeping = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblPayment (
paymentID TEXT (6),
dob DATE,
amountPaid CURRENCY,
customerID TEXT (6),
primary key (paymentID),
foreign key (customerID) REFERENCES tblCustomer(customerID)
)""")
tblPayment = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblOrder(
orderID TEXT (6),
price CURRENCY,
customerID TEXT (6),
treatmentID TEXT (6),
primary key (orderID),
foreign key (customerID) REFERENCES tblCustomer(customerID),
foreign key (treatmentID) REFERENCES tblTreatment(treatmentID)
)""")
tblOrder = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblTreatment(
treatmentID TEXT (6),
treatmentType TEXT (20),
extras TEXT(20),
employeeID TEXT (6),
primary key (treatmentID),
foreign key (employeeID) REFERENCES tblEmployee(employeeID)
)""")
tblTreatment = []
cursor.execute("""CREATE TABLE IF NOT EXISTS tblUser (
userID TEXT (6),
firstName TEXT (10),
secondName TEXT (15),
username VARCHAR(20),
password VARCHAR (20),
primary key (userID)
)""")
tblUser = []