-
Notifications
You must be signed in to change notification settings - Fork 2
/
db.py
39 lines (31 loc) · 1.09 KB
/
db.py
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
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, Text, String, DateTime, Boolean
from sqlalchemy.dialects.postgresql import ARRAY
Base = declarative_base()
class Story(Base):
__tablename__ = "posts"
id = Column(Integer, primary_key=True)
title = Column(String)
by = Column(String)
time = Column(DateTime)
text = Column(Text, nullable=True)
url = Column(String, nullable=True)
host = Column(String, nullable=True)
score = Column(Integer)
kids = Column(ARRAY(Integer, dimensions=1))
dead = Column(Boolean)
descendants = Column(Integer)
all_kids = Column(ARRAY(Integer, dimensions=1), nullable=True)
is_ask = Column(Boolean)
is_show = Column(Boolean)
is_tell = Column(Boolean)
is_job = Column(Boolean)
class Comment(Base):
__tablename__ = "comments"
id = Column(Integer, primary_key=True)
by = Column(String)
time = Column(DateTime)
text = Column(Text)
kids = Column(ARRAY(Integer, dimensions=1))
parent_id = Column(Integer, index=True)
dead = Column(Boolean)