MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / fetchval

Method fetchval

asyncpg/connection.py:725–744  ·  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

723 )
724
725 async def fetchval(self, query, *args, column=0, timeout=None):
726 """Run a query and return a value in the first row.
727
728 :param str query: Query text.
729 :param args: Query arguments.
730 :param int column: Numeric index within the record of the value to
731 return (defaults to 0).
732 :param float timeout: Optional timeout value in seconds.
733 If not specified, defaults to the value of
734 ``command_timeout`` argument to the ``Connection``
735 instance constructor.
736
737 :return: The value of the specified column of the first record, or
738 None if no records were returned by the query.
739 """
740 self._check_open()
741 data = await self._execute(query, args, 1, timeout)
742 if not data:
743 return None
744 return data[0][column]
745
746 async def fetchrow(
747 self,

Callers

nothing calls this directly

Calls 2

_check_openMethod · 0.95
_executeMethod · 0.95

Tested by

no test coverage detected