id = db.Column(db.Integer, primary_key=True) unliker_id = db.Column(db.Integer) unliked_id = db.Column(db.Integer) def to_json(self): unlike_json = { 'unliker_id': self.unliker_id, 'unliked_id': self.unliked_id } return unlike_json @staticmethod def from_json(unlike): unliker_id = unlike.get('unliker_id') unliked_id = unlike.get('unliked_id') return Unlike(unliker_id=unliker_id, unliked_id=unliked_id) def __repr__(self): return '<Row %r>' % self.id def make_shell_context(): return dict(app=app, db=db, User=User, UserProfile=UserProfile, Like=Like, Unlike=Unlike) manager.add_command("shell", Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) if __name__ == '__main__': search.create_index(update=True) manager.run()
question = db.Column(db.String(500)) answer = db.Column(db.Text) def to_dict(self): resp_dict = { "id": self.id, "question": self.question, "answer": self.answer } return resp_dict def __repr__(self): return '<Faq:{}>'.format(self.id) search.create_index(Faq) # db.create_all() # print("创建faq表格成功") @app.route("/insertFaq") def insert_faq(): """ 插入FAQ数据 :return: """ qa_list = get_question_answer_list() faq_list = [] for qa in qa_list: qa_obj = Faq(question=qa[0], answer=qa[1])