Skip to content

Commit

Permalink
Add record_class parameter Pool.fetch and Pool.fetchrow
Browse files Browse the repository at this point in the history
  • Loading branch information
baltitenger committed Mar 25, 2022
1 parent a2f093d commit 7eec0df
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions asyncpg/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,13 @@ async def executemany(self, command: str, args, *, timeout: float=None):
async with self.acquire() as con:
return await con.executemany(command, args, timeout=timeout)

async def fetch(self, query, *args, timeout=None) -> list:
async def fetch(
self,
query,
*args,
timeout=None,
record_class=None
) -> list:
"""Run a query and return the results as a list of :class:`Record`.
Pool performs this operation using one of its connections. Other than
Expand All @@ -586,7 +592,12 @@ async def fetch(self, query, *args, timeout=None) -> list:
.. versionadded:: 0.10.0
"""
async with self.acquire() as con:
return await con.fetch(query, *args, timeout=timeout)
return await con.fetch(
query,
*args,
timeout=timeout,
record_class=record_class
)

async def fetchval(self, query, *args, column=0, timeout=None):
"""Run a query and return a value in the first row.
Expand All @@ -602,7 +613,7 @@ async def fetchval(self, query, *args, column=0, timeout=None):
return await con.fetchval(
query, *args, column=column, timeout=timeout)

async def fetchrow(self, query, *args, timeout=None):
async def fetchrow(self, query, *args, timeout=None, record_class=None):
"""Run a query and return the first row.
Pool performs this operation using one of its connections. Other than
Expand All @@ -612,7 +623,12 @@ async def fetchrow(self, query, *args, timeout=None):
.. versionadded:: 0.10.0
"""
async with self.acquire() as con:
return await con.fetchrow(query, *args, timeout=timeout)
return await con.fetchrow(
query,
*args,
timeout=timeout,
record_class=record_class
)

async def copy_from_table(
self,
Expand Down

0 comments on commit 7eec0df

Please sign in to comment.