-2
def add_student():
with sqlite3.connect("BehaviourManagement.db") as db:
cursor = db.cursor()
ID = 1
first_name = input("Enter student first name: ")
surname = input("Enter student surname: ")
year_group = int(input("Enter student year group: "))
strike = 0
new_student_info = (ID, first_name, surname, year_group, strike)
cursor.execute(insert_to_students, new_student_info)
db.commit()
ID = ID + 1
CREATE TABLE students(
ID INTEGER,
first_name TEXT,
Surname TEXT,
year_group INTEGER,
strike INTEGER,
Primary Key(ID));
나는이 오류 메시지가 도착 2 개 값 :오류 해결 방법 : 5 열
이Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "M:\computer science a2\comp 3\login.py", line 59, in add_student
cursor.execute(insert_to_students, new_student_info)
sqlite3.OperationalError: 2 values for 5 columns
실제로 실행되는 코드가 맞습니까? 'execute' 줄 앞에'print (insert_to_students, new_student_info)'를 시도하십시오. –