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)
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)