def scalar(self):
    'Return the first element of the first result or None\n        if no rows present.  If multiple rows are returned,\n        raises MultipleResultsFound.\n\n          >>> session.query(Item).scalar()\n          <Item>\n          >>> session.query(Item.id).scalar()\n          1\n          >>> session.query(Item.id).filter(Item.id < 0).scalar()\n          None\n          >>> session.query(Item.id, Item.name).scalar()\n          1\n          >>> session.query(func.count(Parent.id)).scalar()\n          20\n\n        This results in an execution of the underlying query.\n\n        '
    try:
        ret = self.one()
        if (not isinstance(ret, tuple)):
            return ret
        return ret[0]
    except orm_exc.NoResultFound:
        return None
Return the first element of the first result or None
if no rows present.  If multiple rows are returned,
raises MultipleResultsFound.

  >>> session.query(Item).scalar()
  <Item>
  >>> session.query(Item.id).scalar()
  1
  >>> session.query(Item.id).filter(Item.id < 0).scalar()
  None
  >>> session.query(Item.id, Item.name).scalar()
  1
  >>> session.query(func.count(Parent.id)).scalar()
  20

This results in an execution of the underlying query.
def scalar(self):
    'Return the first element of the first result or None\n        if no rows present.  If multiple rows are returned,\n        raises MultipleResultsFound.\n\n          >>> session.query(Item).scalar()\n          <Item>\n          >>> session.query(Item.id).scalar()\n          1\n          >>> session.query(Item.id).filter(Item.id < 0).scalar()\n          None\n          >>> session.query(Item.id, Item.name).scalar()\n          1\n          >>> session.query(func.count(Parent.id)).scalar()\n          20\n\n        This results in an execution of the underlying query.\n\n        '
    try:
        ret = self.one()
        if (not isinstance(ret, tuple)):
            return ret
        return ret[0]
    except orm_exc.NoResultFound:
        return None