创建学生库
类型:程序题

题目说明

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()

评分标准

(1)students.db 或等效答案;(2分) (2)CREATE TABLE 或等效答案; (2分) (3)WHERE age > 18 或等效答案;(3分) (4)fetchall() 或等效答案。(3分)

代码编辑器 加载中...
留空使用题目默认限制
{{resultStatus.text}}
正在加载运行记录...
乐编题库AI助手
人工客服
微信扫码联系客服
历史对话
{{ s.title || '未命名对话' }}
{{ s.created_at }}
暂无历史对话
我能帮助你什么?