Skip to content

Commit

Permalink
Comments been removed after parent post deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
DogukanUrker committed Dec 28, 2023
1 parent 72b388b commit fc2a05d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ def deletePost(postID):
cursor.execute(f"delete from posts where id = {postID}")
cursor.execute(f"update sqlite_sequence set seq = seq-1")
connection.commit()
connection.close()
connection = sqlite3.connect("db/comments.db")
cursor = connection.cursor()
cursor.execute(f"select count(*) from comments where post = {postID}")
commentCount = list(cursor)[0][0]
cursor.execute(f"delete from comments where post = {postID}")
cursor.execute(f"update sqlite_sequence set seq = seq - {commentCount}")
connection.commit()
message("2", f'POST: "{postID}" DELETED')


Expand Down

0 comments on commit fc2a05d

Please sign in to comment.