Updates data in the table.
        
        :Parameters: 

        - query(dict), specify the WHERE clause
        - attributes(dict), specify the SET clause
        - upsert: boolean. If True, then when there's no row matches the query, insert the values

        :Return: Number of rows updated or inserted

def update(self, query, attributes, upsert=False):
        """
        Updates data in the table.
        
        :Parameters: 

        - query(dict), specify the WHERE clause
        - attributes(dict), specify the SET clause
        - upsert: boolean. If True, then when there's no row matches the query, insert the values

        :Return: Number of rows updated or inserted
        """
        if upsert:
            found_result = self.find_one(query)
            if not found_result:
                id = self.insert(attributes)
                if id > 0:
                    return 1
                else:
                    return 0

        sql = build_update(self.name, query, attributes)
        return self.cursor.execute(sql)