4949fe1ef30e974dffdf8c8664a1eda14f410135
1 from sqlalchemy
import *
4 from sqlalchemy
.ext
.declarative
import declarative_base
5 TableBase
= declarative_base(bind
=migrate_engine
)
8 class Forum(TableBase
):
9 __tablename__
= 'forums'
10 id = Column(Integer
, primary_key
=True, autoincrement
=True, nullable
=False)
11 name
= Column(Unicode(133), nullable
=False)
13 class Thread(TableBase
):
14 __tablename__
= 'threads'
15 id = Column(Integer
, primary_key
=True, autoincrement
=True, nullable
=False)
16 forum_id
= Column(Integer
, ForeignKey('forums.id'), nullable
=False)
17 subject
= Column(Unicode(133), nullable
=False)
19 class Post(TableBase
):
20 __tablename__
= 'posts'
21 id = Column(Integer
, primary_key
=True, autoincrement
=True, nullable
=False)
22 thread_id
= Column(Integer
, ForeignKey('threads.id'), nullable
=False)
23 posted_time
= Column(DateTime
, nullable
=False)
24 content
= Column(Unicode(5120), nullable
=False)
28 Forum
.__table__
.create()
29 Thread
.__table__
.create()
30 Post
.__table__
.create()
34 Thread
.__table__
.drop()
35 Forum
.__table__
.drop()