From 19fce5f1b45f19cb3271f832432e952d3e3737bf Mon Sep 17 00:00:00 2001 From: Oleg Silkin Date: Tue, 16 Jul 2019 20:21:35 -0400 Subject: [PATCH] Adds comment deletion query --- src/database.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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