database_module #17

Merged
Miroslavsckaya merged 20 commits from database_interaction into master 2022-05-29 20:19:18 +00:00
Showing only changes of commit b31cfb99aa - Show all commits

View file

@ -48,5 +48,13 @@ class Database():
return self.cur.fetchall()
def find_feed_items(self, feed_id: int) -> list:
self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = (?)', [feed_id])
return self.cur.fetchall()
self.cur.execute('SELECT * FROM feeds_last_items WHERE feed_id = ?', [feed_id])
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()