Example #1
0
 def find_by_keys(self, __type_id, __use_id, __technology_id, session=None):
     if session is None:
         session = DBSession()
     return session.query(LightInfosBean)\
         .filter(LightInfosBean.type_id == __type_id) \
         .filter(LightInfosBean.use_id == __use_id) \
         .filter(LightInfosBean.technology_id == __technology_id).first()
Example #2
0
 def has_fetch(self, __url, session=None):
     if session is None:
         session = DBSession()
     url_manager = self.find_by_url(__url, session)
     if url_manager is None:
         return False
     else:
         return True
 def safe_insert(self, __type, session=None):
     if session is None:
         session = DBSession()
     try:
         if self.find_by_key(__type.type_id, session) is None:
             session.add(__type)
             session.commit()
     except BaseException as e:
         session.rollback()
         logger.error(e)
 def insert(self, entity, session=None):
     if session is None:
         session = DBSession()
     try:
         session.add(entity)
         session.commit()
     except BaseException as e:
         session.rollback()
         print(e)
         logger.error(e)
Example #5
0
 def safe_insert(self, __light_infos, session=None):
     if session is None:
         session = DBSession()
     try:
         if self.find_by_keys(__light_infos.type_id, __light_infos.use_id,
                              __light_infos.technology_id, session) is None:
             session.add(__light_infos)
             session.commit()
     except BaseException as e:
         session.rollback()
         logger.error(e)
 def count_type(self, session=None):
     """总数"""
     if session is None:
         session = DBSession()
     return session.query(TypeBean).count()
 def select_by_page(self, offset, limit, session=None):
     """查询,offset起始位置,limit 返回条数 """
     if session is None:
         session = DBSession()
         return session.query(TypeBean).offset(offset).limit(limit).all()
 def select_by_model(self, __model_id, session=None):
     if session is None:
         session = DBSession()
     return session.query(TypeBean).filter_by(model_id=__model_id).all()
 def find_by_key(self, __id, session=None):
     if session is None:
         session = DBSession()
     return session.query(TypeBean).filter(TypeBean.type_id == __id).first()
 def select_by_type(self, __type_id, session=None):
     if session is None:
         session = DBSession()
     return session.query(LightBean).filter_by(type_id=__type_id).all()
 def find_by_type_use(self, __type_id, __use_id, session=None):
     if session is None:
         session = DBSession()
     return session.query(TechnologyBean)\
         .filter(TechnologyBean.type_id == __type_id) \
         .filter(TechnologyBean.use_id == __use_id).all()
 def select_all(self, entity, session=None):
     if session is None:
         session = DBSession()
     return session.query(entity).all()
 def select_by_manufacturer(self, __manufacturer_id, session=None):
     if session is None:
         session = DBSession()
     return session.query(ModelBean).filter_by(
         manufacturer_id=__manufacturer_id).all()
 def find_by_key(self, __id, session=None):
     if session is None:
         session = DBSession()
     return session.query(ModelBean).filter(
         ModelBean.model_id == __id).first()
Example #15
0
 def find_by_key(self, __id, session=None):
     if session is None:
         session = DBSession()
     return session.query(UrlManager).filter(UrlManager.id == __id).first()
Example #16
0
 def find_by_url(self, __url, session=None):
     if session is None:
         session = DBSession()
     return session.query(UrlManager).filter(
         UrlManager.url == __url).first()