from app import Story, Paragraph, db
|
|
from datetime import datetime
|
|
|
|
db.drop_all()
|
|
db.create_all()
|
|
|
|
BEGIN_WORDS = [("候选%d的标题" % (i + 1), "第%d个故事的示例开头" % (i + 1)) for i in range(10)]
|
|
|
|
for idx, (t, w) in zip(range(10), BEGIN_WORDS):
|
|
s = Story(id=idx, title=t, text=w, tail=idx,
|
|
avatar="https://bbs.pku.edu.cn/v2/images/user/portrait-anony.png")
|
|
p = Paragraph(id=idx, text=w, story_id=idx, is_chosen=True,
|
|
author="初始设定", time=datetime.now())
|
|
db.session.add(s)
|
|
db.session.add(p)
|
|
|
|
db.session.commit()
|