add database

This commit is contained in:
Rykov7
2023-02-25 19:33:39 +03:00
parent d0cf0762c8
commit fd069a9615
7 changed files with 88 additions and 54 deletions
+30
View File
@@ -0,0 +1,30 @@
from sqlalchemy import Column, String, Integer, Boolean, ForeignKey
from sqlalchemy.orm import relationship, declarative_base
Base = declarative_base()
class Quote(Base):
__tablename__ = "quotes"
id = Column(Integer, primary_key=True)
chat_id = Column(Integer, ForeignKey('chats.chat_id'))
text = Column(String)
def __repr__(self):
return f"Quote({self.text=}, {self.chat_id=})"
class Chat(Base):
__tablename__ = "chats"
id = Column(Integer, primary_key=True)
chat_id = Column(Integer, unique=True)
title = Column(String)
# Settings
quotes = relationship('Quote', backref='chat')
antispam = Column(Boolean)
report = Column(Boolean)
reminder = Column(Boolean)
def __repr__(self):
return f'Chat({self.chat_id=}, {self.title=})'