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 b4ed8070d5 - Show all commits

View file

@ -13,18 +13,21 @@ class Database():
self.conn.commit()
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})
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:
self.cur.execute('INSERT INTO feeds (link) VALUES (:link)', {'link': link})
self.conn.commit()
return self.cur.lastrowid
def delete_feed():
pass
def delete_feed(self, feed_id: int) -> None:
self.cur.execute('DELETE FROM feeds WHERE id = :feed_id', {'feed_id': feed_id})
self.conn.commit()
def get_feeds():
pass