Skip to content

Commit 23394c9

Browse files
khazhykelprans
authored andcommitted
Document that single fetches can return None
fetchrow() and fetchval() return None if no result, as opposed to for example raising.
1 parent 1fed2a9 commit 23394c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

asyncpg/connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ async def fetchval(self, query, *args, column=0, timeout=None):
352352
``command_timeout`` argument to the ``Connection``
353353
instance constructor.
354354
355-
:return: The value of the specified column of the first record.
355+
:return: The value of the specified column of the first record, or
356+
None if no records were returned by the query.
356357
"""
357358
self._check_open()
358359
data = await self._execute(query, args, 1, timeout)
@@ -367,7 +368,8 @@ async def fetchrow(self, query, *args, timeout=None):
367368
:param args: Query arguments
368369
:param float timeout: Optional timeout value in seconds.
369370
370-
:return: The first row as a :class:`Record` instance.
371+
:return: The first row as a :class:`Record` instance, or None if
372+
no records were returned by the query.
371373
"""
372374
self._check_open()
373375
data = await self._execute(query, args, 1, timeout)

0 commit comments

Comments
 (0)