-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtables.py
More file actions
70 lines (62 loc) · 1.54 KB
/
tables.py
File metadata and controls
70 lines (62 loc) · 1.54 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from sqlalchemy import (
Integer,
String,
DateTime,
Text,
Date,
CheckConstraint
)
from sqlalchemy.orm import Mapped, mapped_column
from database import Base
from datetime import datetime, date
class EventDB(Base):
__tablename__ = "event_info"
eid: Mapped[int] = mapped_column(
Integer,
primary_key=True,
autoincrement=True
)
description: Mapped[str] = mapped_column(
Text,
nullable=True
)
name: Mapped[str] = mapped_column(
String(64)
)
start_time: Mapped[datetime] = mapped_column(
DateTime(timezone=True)
)
end_time: Mapped[datetime] = mapped_column(
DateTime(timezone=True)
)
repeat: Mapped[str] = mapped_column(
String(64)
)
start_date: Mapped[date] = mapped_column(
Date,
nullable=True
)
end_date: Mapped[date] = mapped_column(
Date,
nullable=True
)
__table_args__ = (
CheckConstraint(
'start_time < end_time',
name='check_start_time_before_end_time'
),
CheckConstraint(
'start_date < end_date',
name='check_start_date_before_end_date'
)
)
def serialize(self) -> dict:
return{
"eid": self.eid,
"name": self.name,
"description": self.description,
"start_time": self.start_time,
"end_time": self.end_time,
"start_date": self.start_date,
"end_date": self.end_date,
}