使用Python的sqlite3库完成以下需求并补全代码:
students的数据库;students_table的表,包含字段:id(主键)、name(学生姓名)、age(学生年龄)、grade(学生年级);students_table中插入至少5个学生的数据;Alice的学生的年龄增加1岁;Bob的学生。(本题无需运行通过,写入代码即可)
import sqlite3
conn = sqlite3.connect('①')
cursor = conn.cursor()
cursor.execute('''
② students_table(id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,age INTEGER,grade TEXT)''')
students = [('Alice', 17, '10th'), ('Bob', 18, '11th'), ('Charlie', 16, '10th'), ('David', 19, '12th'), ('Eve', 17, '11th')]
cursor.executemany('''INSERT INTO students_table (name, age, grade) VALUES (?, ?, ?)''', students)
conn.commit()
cursor.execute('SELECT * FROM students_table ③')
print("年龄大于18岁的学生:")
print(cursor.④)
cursor.execute('UPDATE students_table SET age = age + 1 WHERE name = "Alice"')
cursor.execute('DELETE FROM students_table WHERE name = "Bob"')
conn.commit()
conn.close()