-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.py
More file actions
33 lines (29 loc) · 1.02 KB
/
storage.py
File metadata and controls
33 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sqlite3
import os
class Storage:
def __init__(self, db_path="scout.db"):
self.db_path = db_path
self._init_db()
def _init_db(self):
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS processed_issues (
issue_id INTEGER PRIMARY KEY
)
""")
conn.commit()
conn.close()
def is_processed(self, issue_id: int) -> bool:
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
cursor.execute("SELECT 1 FROM processed_issues WHERE issue_id = ?", (issue_id,))
result = cursor.fetchone()
conn.close()
return result is not None
def mark_processed(self, issue_id: int):
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
cursor.execute("INSERT OR IGNORE INTO processed_issues (issue_id) VALUES (?)", (issue_id,))
conn.commit()
conn.close()