add delete_feed method
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
mitsuha_s 2022-05-22 22:41:37 +00:00
parent 6db0da68be
commit b4ed8070d5

View file

@ -13,18 +13,21 @@ class Database():
self.conn.commit() self.conn.commit()
return self.cur.lastrowid return self.cur.lastrowid
def get_user(self, telegram_id: str) -> tuple | None: def get_user(self, telegram_id: str) -> int | None:
self.cur.execute('SELECT id FROM users WHERE telegram_id = :telegram_id', {'telegram_id': telegram_id}) self.cur.execute('SELECT id FROM users WHERE telegram_id = :telegram_id', {'telegram_id': telegram_id})
user_id = self.cur.fetchone() user_id = self.cur.fetchone()
return user_id if user_id is None:
return None
return user_id[0]
def add_feed(self, link: str) -> int: def add_feed(self, link: str) -> int:
self.cur.execute('INSERT INTO feeds (link) VALUES (:link)', {'link': link}) self.cur.execute('INSERT INTO feeds (link) VALUES (:link)', {'link': link})
self.conn.commit() self.conn.commit()
return self.cur.lastrowid return self.cur.lastrowid
def delete_feed(): def delete_feed(self, feed_id: int) -> None:
pass self.cur.execute('DELETE FROM feeds WHERE id = :feed_id', {'feed_id': feed_id})
self.conn.commit()
def get_feeds(): def get_feeds():
pass pass