Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
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)