code: def count(self, query=None, distinct=False, distinct_fields=None):
          
          if distinct_fields is None:
              self.__ensure_columns()
              if distinct:
                  field = ','.join(self.columns)
              else:
                  field = '*'
          else:
              field = ','.join(distinct_fields)
  
          if distinct:
              count_str = 'DISTINCT(%s)' %(field)
          else:
              count_str = field
  
          count_str = 'COUNT(%s)' %(count_str)
  
          sql = 'SELECT %s FROM %s' %(count_str, self.name)
  
          if query is not None:
              query_str = build_query(query)
              if query_str:
                  sql = sql + ' WHERE ' + query_str
  
          self.cursor.execute(sql)
          count = self.cursor.fetchone()[0]
  
          return count
docs: Returns the number of rows satisying a criteria, if provided.
          
          :Parameters: 
  
          - query: specify the WHERE clause
          - distinct : boolean, whether to use DISTINCT()
          - distinct_fields : list or tuple or strings. Each string is
            a column name used inside COUNT(). If none, '*' will be
            used.
  
          :Return: int, the number of rows