-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
30 lines (21 loc) · 946 Bytes
/
Copy pathmodels.py
File metadata and controls
30 lines (21 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from datetime import datetime
from sqlalchemy import BigInteger, DateTime, Integer, String, Text, func
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class News(Base):
__tablename__ = "news"
id: Mapped[int] = mapped_column(primary_key=True)
url: Mapped[str] = mapped_column(String, unique=True, nullable=False)
title: Mapped[str | None] = mapped_column(String, nullable=True)
image: Mapped[str | None] = mapped_column(String, nullable=True)
text: Mapped[str | None] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), default=func.now(), nullable=False
)
class LastSentNews(Base):
__tablename__ = "last_sent_news"
chat_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
last_news_id: Mapped[int] = mapped_column(
Integer, nullable=True, default=0
)