def update(self): args = list(map(self.get_value_or_default, self.__fields__)) args.append(self.get_values(self.__primary_key__)) rows = execute(self.__update__, args) if rows != 1: logging.warning('failed to update by primary key: affected rows: %s' % rows) return rows
def save(self): args = list(map(self.get_value_or_default, self.__fields__)) args.append(self.get_value_or_default(self.__primary_key__)) rows = execute(self.__insert__, args) if rows != 1: logging.warning('failed to insert record: affected rows: %s' % rows) return rows
def create_tables(sqls): for sql in sqls: yield execute(sql)
def remove(self): args = [self.get_values(self.__primary_key__)] rows = execute(self.__delete__, args) if rows != 1: logging.warning('failed to remove by primary key: affected rows: %s' % rows) return rows