def generate_comments():
cakeIds = [11, 21, 31, 41]
stars = [2, 3, 4, 5]
comments = [u'????', u'????', u'????', u'?????']
for i in range(len(cakeIds)):
comm = Comment(id=i+1, userId=1, cakeId=cakeIds[i], stars=stars[i], comment=comments[i])
db.session.add(comm)
try:
db.session.commit()
print 'generate comments successfully'
except IntegrityError:
db.session.rollback()
print 'fail to generate comments'
####### class Picture --> table pictures
评论列表
文章目录