discord_intro_quiz_bot/web/models.py

37 lines
1.2 KiB
Python
Raw Normal View History

2024-08-12 08:11:32 +00:00
from sqlalchemy import Column, Integer, String, TIMESTAMP, ForeignKey
2024-08-03 10:29:46 +00:00
from sqlalchemy.ext.declarative import declarative_base
2024-08-12 08:11:32 +00:00
from sqlalchemy.orm import relationship
2024-08-03 10:29:46 +00:00
Base = declarative_base()
class Account(Base):
__tablename__ = 'accounts'
id = Column(Integer, primary_key=True)
user_id = Column(String)
password = Column(String)
2024-08-12 08:11:32 +00:00
active_sessions = relationship("ActiveSession", back_populates="account")
2024-08-03 10:29:46 +00:00
class ActiveSession(Base):
__tablename__ = 'active_sessions'
id = Column(Integer, primary_key=True)
session_id = Column(String)
last_active = Column(TIMESTAMP)
2024-08-12 08:11:32 +00:00
user_id = Column(Integer, ForeignKey('accounts.id'))
account = relationship("Account", back_populates="active_sessions")
2024-08-03 10:29:46 +00:00
class ChannelId(Base):
__tablename__ = 'channel_ids'
id = Column(Integer, primary_key=True)
channel_id = Column(String)
class QuizMaster(Base):
__tablename__ = 'quiz_master'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String)
full_audio_name = Column(String)
intro_audio_name = Column(String)
keyword1 = Column(String)
keyword2 = Column(String)
keyword3 = Column(String)