tuxbot-bot/cogs/utils/models/poll.py

31 lines
837 B
Python
Raw Normal View History

from sqlalchemy.ext.declarative import declarative_base
2019-10-14 00:12:47 +02:00
from sqlalchemy import Column, Integer, BigInteger, JSON, ForeignKey, Boolean
from sqlalchemy.orm import relationship
2019-10-14 00:12:47 +02:00
from werkzeug.security import generate_password_hash, check_password_hash
Base = declarative_base()
class Poll(Base):
__tablename__ = 'polls'
id = Column(Integer, primary_key=True, autoincrement=True)
channel_id = Column(BigInteger)
message_id = Column(BigInteger)
content = Column(JSON)
2019-10-14 00:12:47 +02:00
is_anonymous = Column(Boolean)
2019-10-14 00:12:47 +02:00
available_choices = Column(Integer)
choice = relationship("Responses")
class Responses(Base):
__tablename__ = 'responses'
id = Column(Integer, primary_key=True, autoincrement=True)
2019-10-14 00:12:47 +02:00
user = Column(BigInteger)
poll_id = Column(Integer, ForeignKey('polls.id'))
choice = Column(Integer)