diff --git a/src/database.py b/src/database.py index 0f3e08c..6b5f4e8 100644 --- a/src/database.py +++ b/src/database.py @@ -156,6 +156,14 @@ def get_comments_by_id(conn, comment_ids: list) -> typing.Union[list, None]: )] +def delete_comment_by_id(conn: sqlite3.Connection, comment_id: str): + with conn: + if conn.execute('SELECT 1 FROM COMMENT WHERE CommentId = ? LIMIT 1', (comment_id,)).fetchone(): + conn.execute("DELETE FROM COMMENT WHERE CommentId = ?", (comment_id,)) + return True + return False + + class DatabaseWriter(object): _writer = None