You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import sqlite3
def add_test_students():
"""添加测试学生数据"""
conn = sqlite3.connect('database.db')
cursor = conn.cursor()
# 测试学生数据
test_students = [
('2024001', '谢坷菡', '计算机科学'),
('2024002', '苏诗颖', '软件工程'),
('2024003', '陈梓旸', '人工智能'),
('2024004', '姚思源', '数据科学'),
('2024005', '颜妍妍', '网络安全'),
('2024006', '尹常在', '物联网'),
('2024007', '陈亦旸', '大数据'),
('2024008', '陈紧新', '云计算')
]
# 清空现有数据(可选)
cursor.execute('DELETE FROM students')
cursor.execute('DELETE FROM call_records')
# 插入测试数据
for student_id, name, major in test_students:
cursor.execute('''
INSERT INTO students (student_id, name, major)
VALUES (?, ?, ?)
''', (student_id, name, major))
conn.commit()
conn.close()
print("测试学生数据添加成功!")
print("添加了8个测试学生")
for i, (student_id, name, major) in enumerate(test_students, 1):
print(f"{i}. {name} (学号: {student_id}, 专业: {major})")
if __name__ == '__main__':
add_test_students()