Esempio n. 1
0
 def query_dataframe(cls, *conditions):
     query = session.query(cls).filter(*conditions)
     df = pd.read_sql(query.statement, session.bind)
     return df
Esempio n. 2
0
 def get_by(cls, *conditions):
     model = session.query(cls).filter(*conditions).one_or_none()
     return model
Esempio n. 3
0
 def query(cls, *conditions):
     models = session.query(cls).filter(*conditions).all()
     return models
Esempio n. 4
0
 def get(cls, _id):
     model = session.query(cls).filter(cls._id == _id).one_or_none()
     return model
Esempio n. 5
0
 def update_many(cls, *conditions, **set_op):
     session.query(cls).filter(*conditions).update(set_op)
     session.commit()
Esempio n. 6
0
 def get_by_episode_id(cls, episode_id):
     model = session.query(cls).filter(
         cls.episode_id == episode_id).one_or_none()
     return model
Esempio n. 7
0
 def distinct(cls, fields, *conditions):
     fields = [fields] if isinstance(fields, str) else fields
     exps = [getattr(cls, f) for f in fields]
     return session.query(cls).filter(*conditions).distinct(*exps).all()
Esempio n. 8
0
 def get_by_author_and_bangumi(cls, author_id, bangumi_id):
     model = session.query(cls).filter(
         cls.author_id == author_id,
         cls.bangumi_id == bangumi_id).one_or_none()
     return model
Esempio n. 9
0
 def get_by_bangumi_id(cls, bangumi_id):
     model = session.query(cls).filter(
         cls.bangumi_id == bangumi_id).one_or_none()
     return model
Esempio n. 10
0
 def get_by_name(cls, name):
     model = session.query(cls).filter(cls.name == name).one_or_none()
     return model
Esempio n. 11
0
 def get(cls, question_id):
     model = session.query(cls).filter(
         cls.question_id == question_id).one_or_none()
     return model
Esempio n. 12
0
 def get(cls, topic_id):
     model = session.query(cls).filter(
         cls.topic_id == topic_id).one_or_none()
     return model
Esempio n. 13
0
 def get(cls, article_id):
     model = session.query(cls).filter(
         cls.article_id == article_id).one_or_none()
     return model
Esempio n. 14
0
 def get(cls, answer_id):
     model = session.query(cls).filter(
         cls.answer_id == answer_id).one_or_none()
     return model