我正在尝试创建一个可以从我创建的数据库中删除学生的函数。ValueError:操作参数必须是str(从数据库删除记录)
def remove_students():
cursor = db.cursor()
first_name = input("Enter first name: ")
surname = input("Enter surname: ")
year_group = int(input("Enter year group: "))
student_info = (first_name, surname, year_group)
cursor.execute(student_info, remove_student)
db.commit()
sql_2 = """CREATE TABLE students(
ID SERIAL PRIMARY KEY,
first_name TEXT,
Surname TEXT,
year_group INTEGER,
strike INTEGER,);"""
remove_student = "DELETE FROM students (first_name, surname, year_group) values (?,?,?)"
当我运行这段代码我得到这个错误:
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 112, in remove_students
cursor.execute(student_info, remove_student)
ValueError: operation parameter must be str
我不明白,因为我对年级组进场前加INT。任何帮助将非常感激。
我试过了,但是我得到了同样的错误信息 – toni
你确定吗?你可以请分享更新后的代码作为图像在这里添加为编辑问题! –
oh no ...对不起,它没有狐狸的问题,但现在我得到一个新的错误消息说:cursor.execute(remove_student,student_info) sqlite3.OperationalError:附近“(”:语法错误 – toni