当我添加属性 Auto increment 时,它要我在插入语句中声明该列?

When I add the attribute Auto increment, it wants me to declare the column in my insert statement?

在创建我的 table 时,我已将 a 列声明为 auto_increment 的主键。

但是当我在我的列中插入一行时,它要我添加主键但先声明它,或者当我不输入主键时,它说我没有给它足够的论据。

几乎我去过的每个网站都告诉我,我不必将主键添加到我的插入语句中,因为它会自动递增,但它似乎并没有这样做。

c.execute("""CREATE TABLE IF NOT EXISTS class(

         student_ID INTEGER AUTO_INCREMENT PRIMARY KEY,
         first TEXT,
         last TEXT,
         mark INTEGER,
         target_grade TEXT,
         percentage INTEGER 


)""")

稍后...

c.execute("INSERT INTO class VALUES (?,?,?,?,?)",
          (first,last,mark,target_grade,percentage,)) 

sqlite3.OperationalError: table class has 6 columns but 5 values were supplied

NameError: name 'ID' is not defined

您必须在 INSERT 语句中包含将接收值的列的名称(当然不包括主键列):

c.execute("INSERT INTO class (first, last, mark, target_grade, percentage) VALUES (?,?,?,?,?)",(first,last,mark,target_grade,percentage,))