'Fetch the first column of the first row, and close the result set.
Returns None if no row is present.'

def scalar(self):

    row = self.first()
    if (row is not None):
        return row[0]
    else:
        return None
