32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
import sqlite3
|
|
class Database():
|
|
def __init__(self, path: str) -> None:
|
|
self.conn = sqlite3.connect(path)
|
|
self.cur = self.conn.cursor()
|
|
self.cur.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER, telegram_id NUMERIC NOT NULL UNIQUE, PRIMARY KEY(id))')
|
|
self.cur.execute('CREATE TABLE IF NOT EXISTS feeds (id INTEGER, link TEXT NOT NULL UNIQUE, PRIMARY KEY(id))')
|
|
self.cur.execute('CREATE TABLE IF NOT EXISTS subscribes (user_id INTEGER, feed_id INTEGER, FOREIGN KEY(user_id) REFERENCES users(id), FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
|
self.cur.execute('CREATE TABLE IF NOT EXISTS feeds_last_items (feed_id INTEGER, link TEXT NOT NULL UNIQUE, title TEXT, description TEXT, date NUMERIC, FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
|
|
|
def add_user(self, telegram_id: str) -> int:
|
|
self.cur.execute('INSERT INTO users (telegram_id) VALUES (:telegram_id)', {'telegram_id': telegram_id})
|
|
return self.cur.lastrowid
|
|
|
|
def add_rss_feed():
|
|
pass
|
|
|
|
def delete_rss_feed():
|
|
pass
|
|
|
|
def get_feeds():
|
|
pass
|
|
|
|
def get_users_subscribes():
|
|
pass
|
|
|
|
def get_feed_items():
|
|
pass
|
|
|
|
def storing_feed_content():
|
|
pass
|