add update_feed_items method
This commit is contained in:
parent
dc3889635e
commit
b31cfb99aa
12
database.py
12
database.py
|
@ -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()
|
Loading…
Reference in a new issue