diff --git a/db/Task.py b/db/Task.py new file mode 100644 index 0000000..dae228c --- /dev/null +++ b/db/Task.py @@ -0,0 +1,19 @@ +from db import Base +from sqlalchemy import Column, Integer, String, BigInteger, Date +from datetime import datetime + + +class Task(Base): + __tablename__ = "tasks" + id = Column(Integer, primary_key=True) + message = Column(String, nullable=False) + user = Column(BigInteger, nullable=False) + channel = Column(BigInteger, nullable=False) + date = Column(Date, nullable=False) + creation_date = Column(Date, default=datetime.now()) + + def __init__(self, message: str, user: int, channel: int, date: datetime): + self.message = message + self.user = user + self.channel = channel + self.date = date diff --git a/db/__init__.py b/db/__init__.py index d414ccb..ca98567 100644 --- a/db/__init__.py +++ b/db/__init__.py @@ -5,5 +5,5 @@ from sqlalchemy.ext.declarative import declarative_base engine = create_engine(config.get("db")) Session = sessionmaker(bind=engine) Base = declarative_base() -#from db.foo import Barr +from db.Task import Task Base.metadata.create_all(engine)