add unsubscribe_user method

This commit is contained in:
mitsuha_s 2022-05-28 22:06:34 +00:00
parent 319a21472f
commit 1c105e6ba0

View file

@ -25,10 +25,14 @@ class Database():
self.conn.commit()
return self.cur.lastrowid
def subscribe_user(self, user_id: int, feed_id: int):
def subscribe_user(self, user_id: int, feed_id: int) -> None:
self.cur.execute('INSERT INTO subscribes (user_id, feed_id) VALUES (?, ?)', (user_id, feed_id))
self.conn.commit()
def unsubscribe_user(self, user_id: int, feed_id: int) -> None:
self.cur.execute('DELETE FROM subscribes WHERE feed_id = ? AND user_id = ?', (feed_id, user_id))
self.conn.commit()
def delete_feed(self, feed_id: int) -> None:
self.cur.execute('DELETE FROM feeds WHERE id = ?', (feed_id,))
self.conn.commit()