MCPcopy
hub / github.com/MagicStack/asyncpg / fetchval

Method fetchval

asyncpg/connection.py:702–721  ·  view source on GitHub ↗

Run a query and return a value in the first row. :param str query: Query text. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout: Optional timeout v

(self, query, *args, column=0, timeout=None)

Source from the content-addressed store, hash-verified

700 )
701
702 async def fetchval(self, query, *args, column=0, timeout=None):
703 """Run a query and return a value in the first row.
704
705 :param str query: Query text.
706 :param args: Query arguments.
707 :param int column: Numeric index within the record of the value to
708 return (defaults to 0).
709 :param float timeout: Optional timeout value in seconds.
710 If not specified, defaults to the value of
711 ``command_timeout`` argument to the ``Connection``
712 instance constructor.
713
714 :return: The value of the specified column of the first record, or
715 None if no records were returned by the query.
716 """
717 self._check_open()
718 data = await self._execute(query, args, 1, timeout)
719 if not data:
720 return None
721 return data[0][column]
722
723 async def fetchrow(
724 self,

Callers

nothing calls this directly

Calls 2

_check_openMethod · 0.95
_executeMethod · 0.95

Tested by

no test coverage detected