保存单篇论文到数据库(适配当前表结构)
(conn: sqlite3.Connection, paper: Dict)
| 89 | |
| 90 | |
| 91 | def save_paper(conn: sqlite3.Connection, paper: Dict) -> None: |
| 92 | """保存单篇论文到数据库(适配当前表结构)""" |
| 93 | # 当前表结构:id, arxiv_id, doi, title, authors, institution, abstract, venue, publish_date, embedding, embedding_model, fetched_at, pushed, push_date |
| 94 | conn.execute(""" |
| 95 | INSERT OR REPLACE INTO papers |
| 96 | (arxiv_id, doi, title, abstract, authors, institution, venue, publish_date, fetched_at) |
| 97 | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) |
| 98 | """, ( |
| 99 | paper.get("arxiv_id", ""), |
| 100 | paper.get("doi", ""), |
| 101 | paper.get("title", ""), |
| 102 | paper.get("abstract", ""), |
| 103 | paper.get("authors", ""), |
| 104 | paper.get("venue", ""), # institution 用 venue 填充 |
| 105 | paper.get("venue", ""), |
| 106 | paper.get("publish_date", ""), |
| 107 | datetime.now().isoformat(), |
| 108 | )) |
| 109 | conn.commit() |
| 110 | |
| 111 | |
| 112 | def collect_from_source( |
no test coverage detected