database_module #17
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue