From 6db0da68be4c55e05ff3a84e015799768fce19f8 Mon Sep 17 00:00:00 2001 From: mitsuha_s Date: Sun, 22 May 2022 22:02:17 +0000 Subject: [PATCH] add add_feed method --- database_interaction.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/database_interaction.py b/database_interaction.py index 0b7e717..17c1d42 100644 --- a/database_interaction.py +++ b/database_interaction.py @@ -10,17 +10,20 @@ class Database(): def add_user(self, telegram_id: str) -> int: self.cur.execute('INSERT INTO users (telegram_id) VALUES (:telegram_id)', {'telegram_id': telegram_id}) + self.conn.commit() return self.cur.lastrowid def get_user(self, telegram_id: str) -> tuple | None: self.cur.execute('SELECT id FROM users WHERE telegram_id = :telegram_id', {'telegram_id': telegram_id}) - id = self.cur.fetchone() - return id + user_id = self.cur.fetchone() + return user_id - def add_rss_feed(): - pass - - def delete_rss_feed(): + def add_feed(self, link: str) -> int: + self.cur.execute('INSERT INTO feeds (link) VALUES (:link)', {'link': link}) + self.conn.commit() + return self.cur.lastrowid + + def delete_feed(): pass def get_feeds():