| 70 | return entries |
| 71 | |
| 72 | def insert_into_database(entries): |
| 73 | with sqlite3.connect(db_path) as conn: |
| 74 | cursor = conn.cursor() |
| 75 | for entry in entries: |
| 76 | cursor.execute('SELECT issue_no FROM weekly_summary WHERE issue_no = ?', (entry['issue_no'],)) |
| 77 | if cursor.fetchone() is None: |
| 78 | cursor.execute(''' |
| 79 | INSERT INTO weekly_summary (issue_no, date, article_count, project_count, audio_video_count, hot_topic_count, book_count) |
| 80 | VALUES (?, ?, ?, ?, ?, ?, ?) |
| 81 | ''', ( |
| 82 | entry['issue_no'], |
| 83 | entry['date'], |
| 84 | entry.get('article_count', 0), |
| 85 | entry.get('project_count', 0), |
| 86 | entry.get('audio_video_count', 0), |
| 87 | entry.get('hot_topic_count', 0), |
| 88 | entry.get('book_count', 0) |
| 89 | )) |
| 90 | |
| 91 | def print_all_data(): |
| 92 | with sqlite3.connect(db_path) as conn: |