Commit | Line | Data |
---|---|---|
18cab06a O |
1 | from sqlalchemy import * |
2 | from sqlalchemy.ext.declarative import declarative_base | |
3 | ||
4 | engine = create_engine('sqlite:///rainbow.db', echo=False) | |
5 | Base = declarative_base() | |
6 | ||
b2b933a9 | 7 | |
305ce127 | 8 | class Tweet(Base): |
18cab06a | 9 | |
305ce127 | 10 | __tablename__ = "tweet" |
18cab06a O |
11 | |
12 | rainbow_id = Column(Integer, primary_key=True) | |
13 | tweet_id = Column(Integer) | |
14 | ||
15 | def __init__(self, tweet_id): | |
16 | self.tweet_id = tweet_id | |
17 | ||
b2b933a9 | 18 | |
305ce127 | 19 | class Message(Base): |
20 | ||
21 | __tablename__ = "message" | |
22 | ||
23 | rainbow_id = Column(Integer, primary_key=True) | |
24 | message_id = Column(Integer) | |
25 | ||
26 | def __init__(self, message_id): | |
27 | self.message_id = message_id | |
28 | ||
29 | ||
4cf86720 VNM |
30 | class Theme(Base): |
31 | ||
32 | __tablename__ = "theme" | |
33 | ||
34 | theme_id = Column(Integer, primary_key=True) | |
9e3418f1 | 35 | theme_name = Column(String(20)) |
4cf86720 VNM |
36 | |
37 | def __init__(self, theme_name): | |
38 | self.theme_name = theme_name | |
4cf86720 VNM |
39 | |
40 | ||
2d341029 O |
41 | class List(Base): |
42 | ||
43 | __tablename__ = "list" | |
44 | ||
45 | list_rid = Column(Integer, primary_key=True) | |
46 | list_id = Column(Integer) | |
47 | list_name = Column(String(50)) | |
48 | ||
49 | def __init__(self, list_id, list_name): | |
50 | self.list_id = list_id | |
51 | self.list_name = list_name | |
52 | ||
53 | ||
eb9781ed | 54 | def init_db(): |
b2b933a9 | 55 | Base.metadata.create_all(engine) |