涵盖医院全部科研活动的全方位科研项目管理系统
<pre><code>
# 导入必要的模块
import sqlite3
# 连接到SQLite数据库
conn = sqlite3.connect('jinhua_research_management.db')
cursor = conn.cursor()
# 创建表
cursor.execute('''
CREATE TABLE IF NOT EXISTS researchers (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
department TEXT NOT NULL,
email TEXT UNIQUE NOT NULL
)
''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS projects (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
researcher_id INTEGER,
start_date TEXT,
end_date TEXT,
status TEXT,
FOREIGN KEY(researcher_id) REFERENCES researchers(id)
)
''')
# 插入示例数据
cursor.execute("INSERT INTO researchers (name, department, email) VALUES (?, ?, ?)", ('张三', '计算机科学与技术学院', 'zhangsan@zju.edu.cn'))
cursor.execute("INSERT INTO projects (title, researcher_id, start_date, end_date, status) VALUES (?, ?, ?, ?, ?)", ('人工智能研究', 1, '2023-01-01', '2023-12-31', '进行中'))
# 提交事务
conn.commit()
# 查询数据
cursor.execute("SELECT * FROM researchers")
print(cursor.fetchall())
cursor.execute("SELECT * FROM projects")
print(cursor.fetchall())
# 关闭连接
conn.close()
</code></pre>
Copyright © 医院科研管理系统