correct init database object
This commit is contained in:
parent
f0c4b0425a
commit
60a7648ce4
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,4 +5,4 @@
|
||||||
/.venv
|
/.venv
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
users_subscribes.db
|
/bot.db
|
|
@ -1,20 +1,12 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
class Database():
|
class Database():
|
||||||
__instance = None
|
def __init__(self, path):
|
||||||
|
self.conn = sqlite3.connect(path)
|
||||||
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 = self.conn.cursor()
|
||||||
self.cur.execute('CREATE TABLE users (id INTEGER, telegram_id NUMERIC, PRIMARY KEY(id))')
|
self.cur.execute('CREATE TABLE IF NOT EXISTS 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 IF NOT EXISTS 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 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 feeds_last_items (feed_id INTEGER, link TEXT, title TEXT, description TEXT, date NUMERIC, FOREIGN KEY(feed_id) REFERENCES feeds(id))')
|
self.cur.execute('CREATE TABLE IF NOT EXISTS 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():
|
def add_rss_feed():
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue