From 1b93dd163a1c4ed072695238e9a211911a7f6036 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Sun, 14 Nov 2021 19:10:34 +0700 Subject: [PATCH] not now --- driver/database/__init__.py | 21 --------------------- driver/database/data_sql.py | 34 ---------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 driver/database/__init__.py delete mode 100644 driver/database/data_sql.py diff --git a/driver/database/__init__.py b/driver/database/__init__.py deleted file mode 100644 index f7636b9..0000000 --- a/driver/database/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -import os -import re - -from driver.veez import user as app -from sqlalchemy import create_engine -from config import DATABASE_URL as db -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import scoped_session, sessionmaker - -if db and db.startswith("postgres://"): - app = db.replace("postgres://", "postgresql://", 1) - -BASE = declarative_base() - -def start() -> scoped_session: - engine = create_engine(app) - BASE.metadata.bind = engine - BASE.metadata.create_all(engine) - return scoped_session(sessionmaker(bind=engine, autoflush=False)) - -SESSION = start() diff --git a/driver/database/data_sql.py b/driver/database/data_sql.py deleted file mode 100644 index 737cad5..0000000 --- a/driver/database/data_sql.py +++ /dev/null @@ -1,34 +0,0 @@ -import threading -from driver.database import BASE, SESSION -from sqlalchemy import Column, String, UnicodeText - - -class Chats(BASE): - __tablename__ = "chats" - chat_id = Column(String(14), primary_key=True) - chat_name = Column(UnicodeText) - - def __init__(self, chat_id, chat_name=None): - self.chat_id = chat_id - self.chat_name = chat_name - -Chats.__table__.create(checkfirst=True) - -CHATS_LOCK = threading.RLock() -CHATS_DATA = set() - -def del_chat(chat_id): - with CHATS_LOCK: - chat = SESSION.query(Chats).get(str(chat_id)) - if chat: - SESSION.delete(chat) - SESSION.commit() - - -def chatdata(): - global CHAT_ID - try: - CHAT_ID = {int(x.chat_id) for x in SESSION.query(Chats).all()} - return CHAT_ID - finally: - SESSION.close()