init database object
This commit is contained in:
parent
5d4a43e2c6
commit
f0c4b0425a
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,3 +3,6 @@
|
||||||
|
|
||||||
# Python
|
# Python
|
||||||
/.venv
|
/.venv
|
||||||
|
|
||||||
|
# Database
|
||||||
|
users_subscribes.db
|
36
database_interaction.py
Normal file
36
database_interaction.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import sqlite3
|
||||||
|
class Database():
|
||||||
|
__instance = None
|
||||||
|
|
||||||
|
def __new__(cls, *args, **kwargs):
|
||||||
|
if cls.__instance is None:
|
||||||
|
cls.__instance = super().__new__(cls)
|
||||||
|
|
||||||
|
return cls.__instance
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.conn = sqlite3.connect('users_subscribes.db')
|
||||||
|
self.cur = self.conn.cursor()
|
||||||
|
self.cur.execute('CREATE TABLE users (id INTEGER, telegram_id NUMERIC, PRIMARY KEY(id))')
|
||||||
|
self.cur.execute('CREATE TABLE feeds (id INTEGER, link TEXT, PRIMARY KEY(id))')
|
||||||
|
self.cur.execute('CREATE TABLE 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 feeds_last_items (feed_id INTEGER, link TEXT, title TEXT, description TEXT, date NUMERIC, FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue