add update_feed_items 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-29 15:16:48 +00:00
parent dc3889635e
commit b31cfb99aa

View file

@ -48,5 +48,13 @@ class Database():
return self.cur.fetchall() return self.cur.fetchall()
def find_feed_items(self, feed_id: int) -> list: def find_feed_items(self, feed_id: int) -> list:
self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = (?)', [feed_id]) self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = ?', [feed_id])
return self.cur.fetchall() return self.cur.fetchall()
def update_feed_items(self, feed_id: int, new_items: list) -> None:
for i in range(len(new_items)):
new_items[i] = (feed_id,) + new_items[i]
self.cur.execute('DELETE FROM feeds_last_items WHERE feed_id = ?', [feed_id])
self.cur.executemany('INSERT INTO feeds_last_items (feed_id, url, title, description, date) VALUES (?, ?, ?, ?, ?)', new_items)
self.conn.commit()